I am working on a project that is using data files from another program. My first attempt at reading the files was to open one of the files in binary mode, read the first 100 bytes and print the data to the terminal. I am not sure how to decipher the data that was displayed. The output that I got was:
b'URES\x04\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x03\t\x00c\x01\x00\x00\x0c#\x00\x00\x02\x1b\x00\x00\x00Y\x00\x00\x00\x08\x98"\x00\x00t\x00\x00\x00\x01\'\x01\x00\x00z$\x00\x00\x04,\xa7\x00\x00\xa1%\x00\x00\x05\x0b\x00\x00\x00o$\x00\x00\n\x11\x00\x00\x00\xcd\xcc\x00\x00\x0b\xf8\x00\x00\x00\xde\xcc\x00\x00\x0c\x19\x00\x00'
I had noticed another question on stack overflow that mentioned URES files, but I was wondering how one could go about figuring out how to read the data from this type of fil开发者_运维技巧e.
Your best bet is to work upstream: find out more about the program that created these files. Find the person maintaining that program and ask them. Find other programs that consume this data.
At the very least, you're going to have to help us by telling us what you know about this data: what is it supposed to be? What field are you even working in? Oil drilling? Medicine? Finance? Architectural drawings? Give us a clue.
The most important thing is finding out what kind of file this is. I've never heard of anything starting with URES, and some quick googling doesn't turn up anything either.
You have more information than we do, so I suggest some searching combining the name of the other program, and all other relevant information you have, and see if you can find a description of the fileformat.
When you have a description, it's all a matter of chopping the input into correctly sized chunks and interpreting it according to the description. For this, the struct module is probably your friend.
精彩评论