Notifications
Clear all

[Closed] Getting rid of a file header

Hey all,

I was wondering if it would be possible for someone to show an example of re-writing a file but skipping the header. Let’s say for instance that you have some tabular data but have a header at the beginning of the file that you don’t want…just the tabular data. I’m basically trying to re-write a .ply file into an .xyz.

Here is a snippet of the file:

ply
  format ascii 1.0
  comment VCGLIB generated
  element vertex 7513550
  property float x
  property float y
  property float z
  property float quality
  element face 0
  property list uchar int vertex_indices
  end_header
  1.98723 -0.861066 0.165241 90 
  1.98248 -0.85899 0.166504 87 
  1.97935 -0.861066 0.166289 89 
  1.97517 -0.860441 0.170998 90

Any help is greatly appreciated!

3 Replies

Why not use a filestream/stringstream and skiptostring?

fs = openfile "some.ply"
skiptostring fs "end_header"

That should position the stream to point just after that line.

-Eric

-- example ---------
ms = MemStreamMgr.openFile "C:\\file.ply"
ms.skipBlock "ply" "end_header" -- skip the header
ms.skipSpace() -- skip space, tab, and newlines

data = ""
while not ms.eos() do data += ms.readLine() + "
"
MemStreamMgr.close ms

expFile = openFile "C:\\file.xyz" mode:"wt"
format "%" data to:expFile
close expFile; free expFile

Thanks for the help!
@ Eric i had tried both skipToString and skipToNextline…but i had them in the wrong spot! Once i moved it as per your example it worked perfect!
@Panayot Thanks…going to study your approach a bit more to see if i can learn something!

Thanks again for the help…i’ll try and post it here once i clean it up a little…maybe it’ll be usful to someone else.