Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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 > 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?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2016-02-12 02:02 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (386 votes), past polls