Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: Read a bin file and extract data

by bulk88 (Priest)
on Mar 22, 2012 at 18:24 UTC ( #961068=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Read a bin file and extract data
in thread Read a bin file and extract data

What is a GCD file and what program or whats the name of the lab equipment that made it? "Shimadzu GC Solution Data File (*.gcd)" ?

LabSolutions PDF

Data Acquisition Offers minimum sampling time of 4 ms, snapshot function, single analys +is and batch analysis capability, Batch Table Wizard, analysis add or insert function, extended analysis time function, automatic data file +name creation, QA/QC (statistical) functions, batch auto-stop functio +n, user program launcher function, pre-run program support, and OLE automation + compatibility (for batch analysis, etc.).
Your program has OLE. Use it. Reverse engineering a binary file is dozens of hours of work and a good knowledge of C (to understand how floating points/LE BE integers/bitfields and structs are layed out in memory). Unless your problem is you need to decode the GCD file on a PC without LabSolutions/Vendor's software or you dont have a license for the hypothetical OLE Addon at your lab? Can't you save the data in some format that is more commonly used?

It will probably be easier for you to spit out ASCII plain text files, like the one you showed, then regex in perl the ASCII plain text report.

I agree. Storage_Lite is terrible to use. I wrote up the following to dump the compound file.
#!/usr/bin/perl -w use strict; use Data::Dumper; use OLE::Storage_Lite; use Encode; use String::Escape qw( backslash ); $Data::Dumper::Useqq = 0; my $ole = OLE::Storage_Lite->new("lab.gcd"); my $oleroot = $ole->getPpsTree([1]); my %cleanoleroot; sub CleanHash { my($full, $clean) = @_; if(ref($full->{'Child'})) { $clean->{Child} = []; foreach(@{$full->{'Child'}}) { my %hash = (); push(@{$clean->{Child}}, \%hash); CleanHash($_, \%hash); } } $clean->{'Name'} = decode('UTF-16LE', $full->{'Name'}); $clean->{'DataEscaped'} = backslash($full->{'Data'}); $clean->{'Data'} = $full->{'Data'}; } CleanHash($oleroot,\%cleanoleroot); print Dumper(\%cleanoleroot);
run this as "perl gcdfile.pl > gcddump.txt", the file will be ~1.5 MB. I changed the name of the GCD file to lab.gcd. Change it to whatever.


Comment on Re^4: Read a bin file and extract data
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://961068]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2014-10-31 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (216 votes), past polls