Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decoding/reading data from a binary file into (an) array(s)

Status
Not open for further replies.

kknorpp001

Technical User
Dec 22, 2003
13
US
Hello.

I need to be able to extract the data from the attached file (or any file in the same format) so that I can work with the data in PHP. I'm fairly comfortable with using PHP with databases, arrays, etc. but have not worked with binary data files.


click on "Download Performance".

The good news is that I know at least most of the information the file contains b/c the program that created the file will export to a csv file (included at the bottom of this message).

Please help. I tried to read using HHD hex editor, but failed to be able to make anything of it. I do know that the data is not encrypted, but it is obviously encoded somehow so I primarily need to figure out how to decode or have someone decode it for me. Please help.

Thanks in advance. The csv file text follows:

[USER DATA]
Ray
AGE=44
WEIGHT=85.7 kg
LOWER HR=60
UPPER HR=221
[END USER DATA]

number of records = 913


ms speed watts rpm hr ss lss rss lpwr rpwr miles wind grade load

" 0"," 0.00"," 0"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0000"," 0"," 0.00"," 0"
" 374"," 2.76"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0001"," 0"," 0.00"," 0"
" 541"," 2.76"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0001"," 0"," 0.00"," 0"
" 559"," 2.76"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0001"," 0"," 0.00"," 0"
" 593"," 7.08"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0002"," 0"," 0.00"," 0"
" 629"," 7.08"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0001"," 0"," 0.00"," 0"
" 646"," 7.08"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0001"," 0"," 0.00"," 0"
" 680"," 7.08"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0004"," 0"," 0.00"," 0"
" 733"," 7.08"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0004"," 0"," 0.00"," 0"
" 733"," 7.08"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0005"," 0"," 0.00"," 0"
" 769"," 7.08"," 4"," 0","100"," 99"," 99"," 99"," 50"," 49"," 0.0005"," 0"," 0.00"," 0"
 
you can use fopen and fread to open and get file data...for csv file you can use the fgetscv() function which automatically read the line as separate values based on the commas.

Its a csv file so no encoding, but you need to know what the fields are to be able to work with them. Ask the file makers what the fields are...

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Didn't work for me either but at 3:am nothing useful would have come of it anyway :)

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Sorry about that. Here is a working link.


Also, I need to clarify that I need to decode the binary file. Long story short, there is a program that will convert the binary file to a .csv so I can use this to help by supplying the .csv file so you know what the data is that is buried in the binary file. But I need to decode the binary file so I don't need to go throught the intermediary step of using the program to convert the file. Please help. Thanks.
 
To be honest, I'm unwilling to go through the effort this would undertake.

My suggestion is, to make the problem easier to solve, is to export 1 record, both in binary and csv, then 5 records. There is some header information at the top of the file that you need to learn to ignore.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Unfortunately, there is no way to export just one record in the binary format. Please help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top