Binary File Operations

From: Jeremy Robbins (robbinj_at_pweh.com)
Date: 07/14/04


Date: 14 Jul 2004 14:45:23 -0700

I am trying to complete some operations on a binary file and was
hoping someone could help speed things up a little for me. I can get
everything to work no problem I would just like to speed it up some.
I have rather large files with a bunch of data points. Each data
point represents a different parameter at a different time, I want to
skip times between points.
This code works below but it seems like I should be able to tell Perl
to read a value and then skip some and then read some more instead of
seeking or looping through the file. THis has been faster then
packing and unpacking everything.

$line = "";
while (read(F,$temp,4*$nparm)){
   $line = $line.$temp;
   sysseek(F,4*($int-1)*$nparm,1);
}
close(F);

#Write the data
   syswrite(OUT,$line,length($line));

(left basic stuff out)
thanks
tex



Relevant Pages

  • Re: Strange problem with structs Linux vs. Mac
    ... I am having a VERY odd problem with unpacking right now. ... I'm reading data from a binary file and then using a very ...
    (comp.lang.python)
  • Re: noob stuck on reading double
    ... Since you're unpacking it with the 'd' format character I am assuming ... a "doubleword" field is a double. ... binary file. ... unpacked = unpack('113d', raw) ...
    (comp.lang.python)
  • writing array to binary file
    ... seems to me the only way is to write one element at a time, which takes *forever* ... is there a way to write the entire array to the binary file without looping. ...
    (microsoft.public.dotnet.languages.vb)