Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.


In reply to Retriving BerkeleyDB Data by hawk2379

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-16 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found