Newbie lost(new info)

Angelo Secchi secchi at sssup.it
Wed Feb 25 20:56:57 CET 2004


I checked with a statistical software(SAS) and I was able to convert my
file using as a format something called s370frb4. that according to its
manual should correspond to a float in C and to a REAL*4 in fortran. Now
I know that the first 3 numbers in the binary part should be exactly: 
 

15612852 	0	 0

I also notice using struct module that

>>> struct.pack('i',15612852)
    '\xb4;\xee\x00'

>>> struct.pack('i',0 )
    '\x00\x00\x00\x00'


not very different (just the order and the F around) from the beginning
of the binary part of my file

13510010222010341341F\xee;\xb4\x00\x00\x00\x00\x00\x00\x00\x00F]\xe3\x9
a\x00


Can these infos help anybody to help me?
Thanks again hoping to be able to throe away any proprietary sofware...
Angelo




On Wed, 25 Feb 2004 18:49:27 +0100
anton at vredegoor.doge.nl (Anton Vredegoor) wrote:

> Angelo Secchi <secchi at sssup.it> wrote:
> 
> >
> >I'm fighting with a binary file and I am definitely lost.
> >I know that each line of the file has a first part that is a string
> >with length 113 and then that there is a group of identical fields. I
> >do not know the precise format of these fields even if I know that
> >the file was created on an IBM Mainframe and that in the binary part
> >there should be 223 fields with the same width 4.
> >Just to give you an idea if I read the first line of my file  as a
> >string I obtain something like (just a small part of the first line):
> >
> >13510010222010341341F\xee;\xb4\x00\x00\x00\x00\x00\x00\x00\x00F]\xe3
> >\x9 a\x00
> >
> >
> >Still I am not able to convert this binary. Can anybody give some
> >advices?
> 
> The string above contains escape sequences, so sometimes four
> characters correspond to one byte, sometimes a char is just a byte.
> This is not really present in the file but just an artifact of the way
> you chose to print it. In order to gain more insight:
> 
> #open the file in binary mode e.g: 
> inf = file('somefile','rb')
> 
> #read 1 line e.g:
> line = inf.readline()
> 
> #turn this line into a list of characters:
> L = list(line)
> 
> #Inspect the list L and come back here with further questions,
> #if you have any :-)
> print L
> 
> Anton
> 
> 
> 
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list


--
========================================================
 Angelo Secchi                     PGP Key ID:EA280337
========================================================
  Current Position:
  Graduate Fellow Scuola Superiore S.Anna
  Piazza Martiri della Liberta' 33, Pisa, 56127 Italy
  ph.: +39 050 883365
  email: secchi at sssup.it	www.sssup.it/~secchi/
========================================================




More information about the Python-list mailing list