Hi Folks
I have been working on a python module which will convert a binary string into a CSV record. A 3rd Party application does this usually, however I'm trying to build this logic into my code. The records before and after conversion are as follows:
CSV Record After Conversion
0029.6,000.87,002.06,0029.2,0010.6,0010.0,0002.1,0002.3,00120,00168,00054,00111,00130,00000,00034,00000,00000,00039,00000,0313.1,11:09:01,06-06-2015,00000169
I'm trying to figure out the conversion logic that has been used by the 3rd party tool, if anyone can help me with some clues regarding this, it would be great!
One thing I have analysed is that each CSV value corresponds to an unsigned short in the byte stream.
TIA, cheers!
As already mentioned, without knowing the binary protocol it will be difficult to guess the exact encoding that is being used. There may be special case logic that is not apparent in the given data.
It would be useful to know the name of the 3rd party application or a least what field this relates to. Anything to give an idea as to what the encoding could be.
The following are clues as you requested on how to proceed:
or:
...you guess two bytes are used so perhaps the others are separate 0 value fields.
and so on... simply convert some of the decimal numbers into hex and search for possible locations in the data. Consider that fields might be big or little endian or a combination thereof.
You should take a look at the struct python library which can be useful in dealing with such conversions once you know the formatting that is being used.
With more data examples the above theories could then be tested.