Export/Import CSV file to Unix DBM database online using cgi programming

djose used Ask the Experts™
I need to create a webpage using cgi programming to build an admin. tool so that the user can import/export a csv file into a Unix DBM database to update it.

Thank you.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
you need to look at a perl module, DBD::CSV, it might work for what you want


I have already written a code in perl to export the dbm filet to csv.....still can't figure out how to import the csv file into the dbm.  Can someone write the code for me or give a sample....How much points is that worth?
sometimes, creating your own code satisfies you than relying on a perl module.

reverse the logic of your export code, and that would generate the import code.

this is the algorithm:

- get the .CSV file to be imported
- open the file and read its contents
- put each line of contents to a %HASH or @ARRAY
- open your DBM file (maybe a flatfile DB)
- consider the field format of both the CSV and DBM
- put each %HASH or @ARRAY contents to the DB file

if you want an example, you may want to show your export code...


Thanks for the suggestion, here is the sample code:

@WriteOrder = ("data1","data2");

     # Define location of datafile
     $DataFile = $ENV{"DOCUMENT_ROOT"} . "/data/" . $query->param("ReferenceNumber") . ".csv";

     # Write the data to file
     open (DATAFILE, ">>$DataFile");
     foreach $Field (@WriteOrder) {
          print DATAFILE "\"$Value\",";
     print DATAFILE "\n";
     close (DATAFILE);

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial