Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

examples using Palm::Addressbook?

by fractureMech (Initiate)
on Sep 07, 2003 at 04:57 UTC ( [id://289549]=perlquestion: print w/replies, xml ) Need Help??

fractureMech has asked for the wisdom of the Perl Monks concerning the following question:

I need to write a script to dump out a Palm Pilot's address book as CSV. I've installed the p5-Palm-1.3.0 module from CPAN, but the documentation of Palm::Addressbook isn't very clear to me (Address.pm docs). Does anyone have a working example?

Replies are listed 'Best First'.
Re: examples using Palm::Addressbook?
by Limbic~Region (Chancellor) on Sep 07, 2003 at 05:31 UTC
    fractureMech,
    Ok - I don't own a Palm Pilot, but I think this will work. With statements from the POD like "I don't know what these are.", I have to agree with your assesment of the documentation. You might also want to take a look at pdbdump which comes with the p5-Palm-1.3.0 suite
    #!/usr/bin/perl -w use strict; use Text::CSV; use Palm::PDB; use Palm::Address; my $pdb = new Palm::PDB; $pdb->Load("myfile.pdb") or die "Unable to attach to address book"; my $csv = Text::CSV->new(); my @order = qw( name firstName company phone1 phone2 phone3 phone4 phone5 address city state zipCode country title custom1 custom2 custom3 custom4 note ); open (OUTPUT, ">address.csv") or die "Unable to open output file : $!" +; select OUTPUT; for my $record (@{$pdb->{records}}) { my @output; for my $field (@order) { if (exists $record->{fields}{$field}) { push @output, $record->{fields}{$field}; } else { push @output, ''; } } if ($csv->combine(@output)) { my $string = $csv->string; print $string, "\n"; } else { my $err = $csv->error_input; print STDOUT "combine() failed on argument: ", $err, "\n"; } }

    Cheers and I hope it helps - L~R

      I get a lot of error messages saying:
      Use of uninitialized value in ... at C:/Perl/site/lib/Palm/PDB.pm line + ...
      when I run your script. I tried looking at pdbdump, but I can't understand it well enough to simplify it. It works and picks out the records, but the format isn't what I want.
        fractureMech,
        Ok - I was working completely blind there since I don't have a Palm myself. The docs as you have noticed are poor and that is all I had to go on. I will install the module and create a brand new PDB and then work backwards, trying to read my records back in after the fact. I will /msg you when I am complete and update this node.

        Cheers - L~R

        Update: After messing around I was able to create a PDB without the use of a Palm Pilot and read it back in. I am not sure what your problem is, so I will either need a copy of your PDB, or would need you to execute the following piece of code and tell me what you get:

        #!/usr/bin/perl -w use strict; use Palm::PDB; use Palm::Address; use Data::Dumper; my $pdb = new Palm::PDB; $pdb->Load("myfile.pdb") or die "Unable to attach to address book"; my $record = $pdb->{records}[0]; print Dumper($record);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://289549]
Approved by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 09:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found