I am reading in a fortran unformatted file. If I use Python to read them in,
import struct
f = open(filename,'r')
values = struct.unpack('%20s',f.read(20))
I get characters like
\xf8, \xbf, \xad, \xe8, \xd8, \xec, \xd5, \x10, \xfd, \xbf
and so on. Each of these are of length one and string replacement functions do not work on them.
What character set am I dealing with?
Edit
pasting partial output of f.read():
\xdf\xde#\xc0|\x18B\x9f\xec\xd6!\xc0]\x0b\x08b\xb1k#\xc0R#g}\xae\x14\xe8?\xde\x1c\x84b\x07S\xe8?.\x0b\x15\x07\xae\x99\xc5\xbf\xac\x9c\xa4\xf0\x8aV\xe4?K\t\x8a(3/\x07@\x97]rW\x8e?\x0b@\xe8\xfe\x9f0\x92P\x04@\xc6&\x98-VV\x07@\xa2\x8e\x86\xa8\xf2-\x18@N\xca\xa6\xc9\xe3W\x1b@\x1f\x96\x0f\xb2\nH\x18@\xc31Jv\xf8\x98\x18@\xacOBu\xcf\xd6'@A\xf0\x9fJ\x84{(@\x1d`.N\x9b\x15'@4\xa5\xb2\x91)\xd3'@\x851\x9d\x83\x98\x00\x02\xc0\xa2Iy\x1b\xca\xf2\x04\xc0eu\rt\xb2\xd5\x04\xc0V\x92\xaf\x9f\xf6\xbd\x02\xc0:\r\xfc\xc6\xf8\xfb\xae\xbf!\x95QZ\xcdx\xe7\xbf\x8e\xd9O\xdf\xd1\xc0\xe4?\xbe\xba\xae\xa5\xb3\x9e\xac\xbfJ0h('=\xf0?\x83\xd67\xcf\n4\xe0?$\xf9\x0c\x00\x05\xe5\xfc?\x97+c\x9d\xd1\xf0?V\xfc\xc8\xe4\x12\x98\xf3?m\x8aa\xc4\xe5}\xf8?s\x9b\xb4{\xf22\x00@\xc3t'\xd0-\xdc\xf5?\xf9\x8eb&Y\x7f\x0c\xc0\x8c\x91\xa7\xe2\xf0|\x0c\xc0d\xd3b\x1a_\x05\x06\xc0u\xa7\x9b\x8e\xcc\xaa\x0b\xc0\xe7\x8a0CG+\x0f\xc0s\x10\x07\x8f
Do you have any information on how the file was written, i.e. what Fortran
writestatements were used? If not, you’ll just be guessing. Keep in mind that unformatted records normally contain binary data, such as integers or floating point numbers, and normally not encoded character data. My guess is you are looking at binary integers. Also you should be opening the file in Python as a binary file ('rb'). That makes a difference on platforms like Windows.Update: Now that you have disclosed that the data is type
real(8), allocatable :: xxx(:)and was written with:it’s clear that the data is binary and not encoded characters.