Re: [Tutor] Reading binary files #2

2009-02-09 Thread eShopping
Hi Bob some replies below. One thing I noticed with the "full" file was that I ran into problems when the number of records was 10500, and the file read got misaligned. Presumably 10500 is still within the range of int? Best regards Alun At 17:49 09/02/2009, bob gailer wrote: etrade.gr

Re: [Tutor] Reading binary files #2

2009-02-09 Thread bob gailer
etrade.griffi...@dsl.pipex.com wrote: Hi following last week's discussion with Bob Gailer about reading unformatted FORTRAN files, I have attached an example of the file in ASCII format and the equivalent unformatted version. Thank you. It is good to have real data to work with. Below is so

Re: [Tutor] Reading binary files #2

2009-02-09 Thread Alan Gauld
wrote I have attached an example of the file in ASCII format and the equivalent unformatted version. Comparing them in vim... It doesn't look too bad except for the DATABEGI / DATAEND message format. That could be tricky to unravel but we have no clear format for MESS. But I assume that all

[Tutor] Reading binary files #2

2009-02-09 Thread etrade . griffiths
Hi following last week's discussion with Bob Gailer about reading unformatted FORTRAN files, I have attached an example of the file in ASCII format and the equivalent unformatted version. Below is some code that works OK until it gets to a data item that has no additional associated data, the

Re: [Tutor] reading binary files

2009-02-04 Thread bob gailer
eShopping wrote: The file is around 800 Mb but I can't get hold of it until next week so suggest starting a new topic once I have a cut-down copy. OK will wait with bated breath. Well, did you read on? What reactions do you have? I did (finally) read on and I am still a little confused, t

Re: [Tutor] reading binary files

2009-02-04 Thread Alan Gauld
"eShopping" wrote I now understand why Python gave me the results it did ... it looks like reading the FORTRAN file will be a non-trivial task so probably best to wait until I can post a copy of it. You don't say which OS you are on but you can read the binary file into a hex editor and see

Re: [Tutor] reading binary files

2009-02-04 Thread eShopping
Bob sorry, I misread your email and thought it said "read on" if the file was FORMATTED. It wasn't so I didn't (but should have). I read the complete thread and it is getting a little messy so I have extracted your questions and added some answers. I'd like to examine the file myself. We

Re: [Tutor] reading binary files

2009-02-04 Thread bob gailer
eShopping wrote: Bob I am trying to read UNFORMATTED files. The files also occur as formatted files and the format string I provided is the string used to write the formatted version. I can read the formatted version OK. I (naively) assumed that the same format string was used for both fil

Re: [Tutor] reading binary files

2009-02-03 Thread eShopping
Bob I am trying to read UNFORMATTED files. The files also occur as formatted files and the format string I provided is the string used to write the formatted version. I can read the formatted version OK. I (naively) assumed that the same format string was used for both files, the only diff

Re: [Tutor] reading binary files

2009-02-03 Thread bob gailer
First question: are you trying to work with the file written UNFORMATTED? If so read on. If you are working with a file formatted (1X, 1X, A8, 1X, 1X, I6, 1X, 1X, A1) then we have a completely different issue to deal with. Do not read on, instead let us know. eShopping wrote: Data format:

Re: [Tutor] reading binary files

2009-02-03 Thread eShopping
Bob At 19:52 03/02/2009, you wrote: etrade.griffi...@dsl.pipex.com wrote: Data format: TIME 1 F 0.0 DISTANCE 10 F 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 F=float, D=double, L=logical, S=string etc The first part of the file should contain a string (eg "TIME"), an integer (1) and ano

Re: [Tutor] reading binary files

2009-02-03 Thread bob gailer
etrade.griffi...@dsl.pipex.com wrote: Data format: TIME 1 F 0.0 DISTANCE 10 F 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 F=float, D=double, L=logical, S=string etc The first part of the file should contain a string (eg "TIME"), an integer (1) and another string (eg "F") so I tried us

Re: [Tutor] reading binary files

2009-02-03 Thread etrade . griffiths
Sorry, still having problems > > I am trying to read data from a file that has format > > item_name num_items item_type items > > > > eg > > > > TIME 1 0.0 > > DISTANCE 10 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 > > Where is the item_type? Ooops, the data format should loo

Re: [Tutor] reading binary files

2009-02-02 Thread Alan Gauld
wrote> I am trying to read data from a file that has format item_name num_items item_type items eg TIME 1 0.0 DISTANCE 10 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 Where is the item_type? I can read this if the data are in ASCII format using in_file = open("my_file.dat",

Re: [Tutor] reading binary files

2009-02-02 Thread jadrifter
On Mon, 2009-02-02 at 11:31 +, etrade.griffi...@dsl.pipex.com wrote: > Hi > > I am trying to read data from a file that has format > > item_name num_items item_type items > > eg > > TIME 1 0.0 > DISTANCE 10 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 > TIME 1 1.0 > DISTANCE

[Tutor] reading binary files

2009-02-02 Thread etrade . griffiths
Hi I am trying to read data from a file that has format item_name num_items item_type items eg TIME 1 0.0 DISTANCE 10 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 TIME 1 1.0 DISTANCE 10 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 I can read this if the data are in ASCII format us