Reading unformatted big-endian files
Andrea Gavana
andrea.gavana at gmail.com
Fri Aug 11 06:35:56 EDT 2006
Hello John,
>Silently ignoring errors when reading a file doesn't sound like a good
>idea to me at all, especially if different records have different
>formats.
Yeah, you're right, but the file itself is quite big and I am
interested only in a small part of it. Moreover, the sequence
keyword-number-keytype is unlikely to fail to be read unless the
simulator that outputs the file does something very strange.
> (a) read the docs on the struct module
Yes, I have done it, and I have written something similar to what you
propose (well, actually your solution is more elegant than mine :-D )
> if keyword == 'DIMENS':
> # 'dimens' is neither declared nor initialised in the FORTRAN
> # so I'm just guessing here ...
Sorry, I forgot to include it, 'dimens' is an integer(4)
Thank you very much for your explanation, now it is very clear what I
should do. I hope performances will not change so much: fortran is
very fast in reading files (but I use it only in this case, I love to
use Python)... well, let's see :-D
Andrea.
--
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/
More information about the Python-list
mailing list