On Tue, Aug 09, 2005 at 06:12:14PM -0400, Brian Bruns wrote:
> Hi,
>
> The problem is that mdb-export was designed to export to CSV format in
> which case " is the proper quoting character. Somewhere along the
> line somebody contributed the -I option.
>
> There is a -R option to set the row delimiter. So you could say something
> like:
>
> mdb-export -I -R ';
> ' Northwind.mdb Shippers
>
> and get the desired results, although I find this sort of a kludge
> since mdb-export doesn't use the delimiter as a mask, everything is
> taken literaly, so the preferable version:
>
> mdb-export -I -R ';\n' Northwind.mdb Shippers
>
> doesn't work as one would hope....that should be a simple fix, I'll
> see if I can get to it this week.
>
> Third option is to use good old sed (which you alluded to) like so:
>
> mdb-export -I Northwind.mdb Shippers | sed -e 's/$/;/'
>
> which will produce the desired results.
>
> As for changing the quoting character, it should be configurable as
> well. Default should be " (double quote) when doing CSV style export
> and ' (single quote) when using the -I switch. I'll see if I can
> knock this out something this week too.
This would be cool. For now I used
mdb-export -S -I StazioniAutomatiche.mdb Misure | sed 's+$+;+g'| tr '"' "'" |
psql meteo
(see the nice 'tr' trick :-).
Markus
> Brian
>
> 2005/8/9, Markus Neteler <neteler@xxxxxx>:
> > Hi,
> >
> > I am currently trying to get MDB data into a PostgreSQL database.
> > Running
> >
> > mdb-export -S -I StazioniAutomatiche.mdb Misure
> > ...
> > INSERT INTO Misure (Id_Misura, Descrizione_Misura, UM) VALUES
> > (236,"Tensione minima giornaliera batteria","V")
> > ...
> >
> > To make PostgreSQL happy, a semicolon is needed at the end of each
> > line (also reported:
> >
> > http://sourceforge.net/mailarchive/forum.php?thread_id=7234522&forum_id=5183
> > ). I have patched src/util/mdb-export.c accordingly (line 185), but I feel
> > that this should go somehow into CVS.
> >
> > A second problem is that all " (double) quotes need to be ' (single) quotes,
> > otherwise PostgreSQL won't insert. Not sure where to fix this one in
> > the C code.
> >
> > I have a shell workaround using tr and sed, but would prefer a fix in
> > the source code (to avoid future traps).
> >
> > Thanks
> >
> > Markus
> >
> >
> >
> > -------------------------------------------------------
> > SF.Net email is Sponsored by the Better Software Conference & EXPO
> > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> > _______________________________________________
> > mdbtools-dev mailing list
> > mdbtools-dev@xxxxxxxxxxxxxxxxxxxxx
> > https://lists.sourceforge.net/lists/listinfo/mdbtools-dev
> >
--
Markus Neteler <neteler itc it> http://mpa.itc.it
ITC-irst - Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18 - 38050 Povo (Trento), Italy
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
|