Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: exporting MS ACCESS tables into a CSV file

by Adrade (Pilgrim)
on Jul 11, 2005 at 20:13 UTC ( #474087=note: print w/replies, xml ) Need Help??


in reply to exporting MS ACCESS tables into a CSV file

If you can export to Excel, you should be able to read it in with Spreadsheet::ParseExcel (if its saved as the correct version, apparently)

Update: I wrote a little dumper for you - hopefully this will help a little. I don't have aparently do have access, so I tested it with it and MySQL, but I think it turns out that DBI's methods are the same for both. All this does is dump all the tables of a database in files of the tables' names, delimited by tabs, but you can easily change that to whatever you want (I just like tabs :-)...
use DBI; my $dbh = DBI->connect("dbi:ODBC:db_test","Admin","password-here", {Ra +iseError => 1, PrintError => 1, AutoCommit => 1} ); my $sel = $dbh->prepare("SELECT [Name] FROM MSysObjects WHERE [Type] = + 1 and [Name] not like 'MSys%'"); $sel->execute; my @tables; while (my ($tab) = $sel->fetchrow_array) { push(@tables, $tab) } $sel->finish; for (@tables) { my $sel = $dbh->prepare("SELECT * FROM $_;"); $sel->execute(); open(DBF,">$_"); print DBF join("\t", @{$sel->{NAME}}), "\n"; while(my (@r) = $sel->fetchrow_array) { for (0..$#r) { $r[$_] =~ s/[\n\r\t]/\?/sg } print DBF join("\t", @r), "\n"; } close(DBF); $sel->finish; }

Really hope this helps,
  -Adam

Update2: The following help is pulled from here:
    After you have installed it, start up a DOS prompt, and type commands as shown below (as lexxwern suggested). PPM is a tool that comes with ActiveState Perl you can use to install Perl modules. Press enter after each command (after installing ActiveState Perl you should have path to ppm.bat).

    ppm
    install DBI
    install DBD::ODBC
    exit

    Then enter control panel, doubleclick on ODBC, click on "System DSN" property sheet, then click button "Add". Select "Microsoft Access Driver (*.mdb), and click "Finish". Type "test" (in this case "db_test") as data source name, click button "Select" and select the Access .mdb file you want to use. The .mdb file should be located below the root of the web server.


Update 3: I could seriously pull my hair out - OK! The code above now works with Microsucks Access - it appears that Access's version of SQL has been totally butchered. Also - make sure you set your permissions correctly within Access so you can access the MSysObjects hidden table... ARGH- MS... err, Access... {rage boils}

Search keywods: show tables in Microsoft Access using SQL - Microsoft Access user permissions

--
By a scallop's forelocks!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2023-02-02 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (19 votes). Check out past polls.

    Notices?