Re: CSV import / export

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Robins Tharakan <tharakan(at)gmail(dot)com>
Cc: pgadmin-hackers(at)postgresql(dot)org
Subject: Re: CSV import / export
Date: 2008-11-27 08:45:05
Message-ID: 492E5E11.9050106@lelarge.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Robins Tharakan a écrit :
> [...]
> While looking at the PgAdmin ToDo list, I saw CSV import as one of the
> things to do. I just wanted to ask a few things before starting work on
> it, so as to ensure that it's envisioned in the way I plan to work on it.
>
> * Apart from CSV import, are we planning to add an 'export' to CSV
> via the Backup dialog box ?

I don't think this is quite the same thing. I would prefer to see a
specific Export menu item in the contextual menu. It would allow to
export datas from view.

> (We could add a 'CSV radio button'
> under 'Format' and change the radio buttons below to things like
> 'Include headers, column separators, etc...).

This seems good to me, but not in the Backup dialog.

> But importantly,
> since its not mentioned in the ToDo, is an export to CSV (of a
> single table) even on the cards ?

Yes, yes, yes :)

> Frankly I ask this also because
> currently the only way to export a table in CSV is to do a 'SELECT
> * FROM table' in SQL query box and save to file, which is quite
> lengthy a process.

You're right. And it would be great too to be able to export to other
formats than CSV.

> * I read a bit about wxWidgets and didn't see any relevant libraries
> there. Are there any 'obvious' libraries (in wxWidgets or
> otherwise) that I should use to parse csv into an array ? For e.g.
> PHP has a pretty neat function like fgetcsv ... that converts a
> csv file to an array of arrays. Anything similar to that, or
> should I have to make that myself ?

None that I know.

> * I have outlined a few details of Import to CSV, please feel free
> to change (or completely rewrite :) the way it should work. I'll
> try and attempt this if no one else is working on it right now.
>
>
> Import to CSV:
>
> 1. 'Restore' option when one right-clicks on a table name, should
> allow for importing via CSV. A radio button above the file
> selection defaults to a 'Backup' file, but has an extra added
> option of a 'CSV file' along with it.

As for export, I would prefer a specific Import menu item.

> 2. (While importing from a CSV file) A set of preferences that could
> allow a user to alter CSV import preferences. For e.g.
> column-separator, line-separators, 'include headers' etc..
> (Personally I'd prefer defaults to these to be modifyable, but
> File-Options-Preferences is too generic for these settings. Any
> better place for such options ?)

Preferences seems the better place to me.

> 3. During import, if an error occurs, A dialogue box is thrown that
> provides for three options. Either mute successive errors if any,
> keep showing them, or altogether stop the import.
>

I think you should have a look at pgloader
(http://pgfoundry.org/projects/pgloader/), at least to get some ideas of
the difficulties it will bring. This projet is written in Python and
tries to ease a restore from a CSV file to a PostgreSQL table.

Last but not least, I think you should work with Quan who also expresses
his wishes to work on this TODO item (see this thread:
http://archives.postgresql.org/pgadmin-hackers/2008-11/msg00099.php).

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

In response to

Browse pgadmin-hackers by date

  From Date Subject
Next Message Guillaume Lelarge 2008-11-27 08:52:16 Re: CSV import / export
Previous Message Quan Zongliang 2008-11-27 05:24:49 Re: CSV import / export