Hello
I am trying to read data from a BerkeleyDB file assocciated with a program called QTstalker.
With the code below, I wanted to print the key and value with the use of perl. My keys come out fine but my values are gibberish.
#!/usr/bin/perl
use strict;
use BerkeleyDB;
my $filename = '/home/user/Perl/AA';
my %h ;
tie %h, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename $! $BerkeleyDB::Error" ;
foreach $key (keys %h)
{
print "$key:";
print "$h{$key}\n";
}
Sample output:
"20140528000000:�Q���*@+@�G�z�*@=
ףp�*@Z�aA
20140529000000:��(\*@)\�(+@�p=
ף*@)\�(+@o�\A
20140904000000:)\�(*@R���Q*@)\��)@*@��ʇA"
Some info I gathered from QTstalker's SourceForge forums:
"The btree structure is simple enough:
Each chart has it's own file somewhere in .qtstalker/data1/data, each entry in the file is a single bar of data:
The keys are strings in this format: "yyyymmddHHMMSS" (eg. "20080128013000", self-explanatory)
The value behind each key are 48 bytes where the first 40 bytes are five doubles representing (open,high,low,close,volume) of the bar. Last 8 bytes is a long integer representing open interest."
Ultimately, I want read the key/value pairs in human form(possibly export to an excel file) and also insert key/values that the database can store for QTstalker.
If someone is kind enough to explain what I am doing wrong and decode what Im looking at, I would greatly appreciate it.