pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedImporting from CSV, auto creating table?
9+ messages / 6 participants
[nested] [flat]
* Importing from CSV, auto creating table?
@ 2019-08-21 21:15 stan <stanb@panix.com>
2019-08-21 21:25 ` Re: Importing from CSV, auto creating table? David G. Johnston <david.g.johnston@gmail.com>
2019-08-21 22:45 ` Re: Importing from CSV, auto creating table? DiasCosta <diascosta@diascosta.org>
2019-08-22 02:36 ` Re: Importing from CSV, auto creating table? Ron <ronljohnsonjr@gmail.com>
2019-08-22 12:25 ` Re: Importing from CSV, auto creating table? Reid Thompson <Reid.Thompson@omnicell.com>
2019-08-23 10:16 ` Re: Importing from CSV, auto creating table? Steve Atkins <steve@blighty.com>
0 siblings, 5 replies; 9+ messages in thread
From: stan @ 2019-08-21 21:15 UTC (permalink / raw)
To: pgsql-general
I have a situation where we need to import data, as an interim measure,
from spreadsheets.
I have read up on \copy and COPY, but I do not see that either of these can
use the header from a CSV file to define a new table. Am I missing
something?
Also downloaded something called pgfutter, which I thought would do this,
but have not had any success with this. After I (thought) I had figured out
the arguments, it just seams to hag forever.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Importing from CSV, auto creating table?
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
@ 2019-08-21 21:25 ` David G. Johnston <david.g.johnston@gmail.com>
4 siblings, 0 replies; 9+ messages in thread
From: David G. Johnston @ 2019-08-21 21:25 UTC (permalink / raw)
To: stan <stanb@panix.com>; +Cc: pgsql-general
On Wed, Aug 21, 2019 at 2:15 PM stan <stanb@panix.com> wrote:
> I have a situation where we need to import data, as an interim measure,
> from spreadsheets.
>
> I have read up on \copy and COPY, but I do not see that either of these can
> use the header from a CSV file to define a new table. Am I missing
> something?
>
>
Nope. You need to create the table separately - or find a tool that will
do that creation for you.
David J.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Importing from CSV, auto creating table?
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
@ 2019-08-21 22:45 ` DiasCosta <diascosta@diascosta.org>
4 siblings, 0 replies; 9+ messages in thread
From: DiasCosta @ 2019-08-21 22:45 UTC (permalink / raw)
To: stan <stanb@panix.com>; pgsql-general
Hi Stan,
I uploaded to the database (PostgreSQL 9.6), monthly and for several
years, over 50 000 000 csv records
using a version of pgtfutter that I compiled (with some changes if I
remember correctly) and the tables
were created in loading process from the column titles.
Dias Costa
On 21-08-2019 22:15, stan wrote:
> I have a situation where we need to import data, as an interim measure,
> from spreadsheets.
>
> I have read up on \copy and COPY, but I do not see that either of these can
> use the header from a CSV file to define a new table. Am I missing
> something?
>
> Also downloaded something called pgfutter, which I thought would do this,
> but have not had any success with this. After I (thought) I had figured out
> the arguments, it just seams to hag forever.
>
>
--
J. M. Dias Costa
Telef. 214026948
Se divulgar esta mensagem por terceiros, por favor:
1. Apague o meu endereço de correio electrónico e o meu nome.
2. Apague também os endereços dos seus amigos antes de distribuir.
3. Enderece como cópia oculta (Cc ou Bcc) para os SEUS destinatários.
Agindo deste modo, dificultará a disseminação de "vírus", "spams" e
"banners" e contribuirá para manter a privacidade de todos e cada um.
Obrigado.
Nota: Não se deverá ao acaso a ocorrência de palavras na minha escrita que não respeitem o
malfadado acordo ortográfico.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Importing from CSV, auto creating table?
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
@ 2019-08-22 02:36 ` Ron <ronljohnsonjr@gmail.com>
2019-08-22 03:14 ` Re: Importing from CSV, auto creating table? David G. Johnston <david.g.johnston@gmail.com>
4 siblings, 1 reply; 9+ messages in thread
From: Ron @ 2019-08-22 02:36 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 8/21/19 4:15 PM, stan wrote:
> I have a situation where we need to import data, as an interim measure,
> from spreadsheets.
>
> I have read up on \copy and COPY, but I do not see that either of these can
> use the header from a CSV file to define a new table. Am I missing
> something?
Data types. Sure, you've got column names from the header line, but what
types do you assign them?
>
> Also downloaded something called pgfutter, which I thought would do this,
> but have not had any success with this. After I (thought) I had figured out
> the arguments, it just seams to hag forever.
>
>
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Importing from CSV, auto creating table?
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
2019-08-22 02:36 ` Re: Importing from CSV, auto creating table? Ron <ronljohnsonjr@gmail.com>
@ 2019-08-22 03:14 ` David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 9+ messages in thread
From: David G. Johnston @ 2019-08-22 03:14 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Wednesday, August 21, 2019, Ron <ronljohnsonjr@gmail.com> wrote:
> On 8/21/19 4:15 PM, stan wrote:
>
>> I have a situation where we need to import data, as an interim measure,
>> from spreadsheets.
>>
>> I have read up on \copy and COPY, but I do not see that either of these
>> can
>> use the header from a CSV file to define a new table. Am I missing
>> something?
>>
>
> Data types. Sure, you've got column names from the header line, but what
> types do you assign them?
Text. I’m gonna post-process anyway, casting to better types isn’t a
problem.
David J.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Importing from CSV, auto creating table?
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
@ 2019-08-22 12:25 ` Reid Thompson <Reid.Thompson@omnicell.com>
2019-08-22 13:01 ` Re: Importing from CSV, auto creating table? Reid Thompson <Reid.Thompson@omnicell.com>
4 siblings, 1 reply; 9+ messages in thread
From: Reid Thompson @ 2019-08-22 12:25 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>; +Cc: Reid Thompson <Reid.Thompson@omnicell.com>
On Wed, 2019-08-21 at 17:15 -0400, stan wrote:
> [EXTERNAL SOURCE]
>
>
>
> I have a situation where we need to import data, as an interim measure,
> from spreadsheets.
>
> I have read up on \copy and COPY, but I do not see that either of these can
> use the header from a CSV file to define a new table. Am I missing
> something?
>
> Also downloaded something called pgfutter, which I thought would do this,
> but have not had any success with this. After I (thought) I had figured out
> the arguments, it just seams to hag forever.
>
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
>
https://csvkit.readthedocs.io/en/latest/tutorial/3_power_tools.html#csvsql-and-sql2csv-ultimate-powe...
csvsql and sql2csv: ultimate power
...snip...
By default, csvsql will generate a create table statement for your data. You can specify what sort of database you are using with the -i flag:
...snip...
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Importing from CSV, auto creating table?
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
2019-08-22 12:25 ` Re: Importing from CSV, auto creating table? Reid Thompson <Reid.Thompson@omnicell.com>
@ 2019-08-22 13:01 ` Reid Thompson <Reid.Thompson@omnicell.com>
2019-08-22 13:14 ` Re: Importing from CSV, auto creating table? Reid Thompson <Reid.Thompson@omnicell.com>
0 siblings, 1 reply; 9+ messages in thread
From: Reid Thompson @ 2019-08-22 13:01 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>; +Cc: Reid Thompson <Reid.Thompson@omnicell.com>
On Thu, 2019-08-22 at 08:25 -0400, Reid Thompson wrote:
> On Wed, 2019-08-21 at 17:15 -0400, stan wrote:
> > [EXTERNAL SOURCE]
> >
> >
> >
> > I have a situation where we need to import data, as an interim measure,
> > from spreadsheets.
> >
> > I have read up on \copy and COPY, but I do not see that either of these can
> > use the header from a CSV file to define a new table. Am I missing
> > something?
> >
> > Also downloaded something called pgfutter, which I thought would do this,
> > but have not had any success with this. After I (thought) I had figured out
> > the arguments, it just seams to hag forever.
> >
> >
> > --
> > "They that would give up essential liberty for temporary safety deserve
> > neither liberty nor safety."
> > -- Benjamin Franklin
> >
> >
>
> https://csvkit.readthedocs.io/en/latest/tutorial/3_power_tools.html#csvsql-and-sql2csv-ultimate-powe...
>
> csvsql and sql2csv: ultimate power
> ...snip...
> By default, csvsql will generate a create table statement for your data. You can specify what sort of database you are using with the -i flag:
> ...snip...
>
Example
https://stackoverflow.com/questions/35243432/how-to-generate-a-schema-from-a-csv-for-a-postgresql-co...
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Importing from CSV, auto creating table?
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
2019-08-22 12:25 ` Re: Importing from CSV, auto creating table? Reid Thompson <Reid.Thompson@omnicell.com>
2019-08-22 13:01 ` Re: Importing from CSV, auto creating table? Reid Thompson <Reid.Thompson@omnicell.com>
@ 2019-08-22 13:14 ` Reid Thompson <Reid.Thompson@omnicell.com>
0 siblings, 0 replies; 9+ messages in thread
From: Reid Thompson @ 2019-08-22 13:14 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>; +Cc: Reid Thompson <Reid.Thompson@omnicell.com>
On Thu, 2019-08-22 at 09:01 -0400, Reid Thompson wrote:
> On Thu, 2019-08-22 at 08:25 -0400, Reid Thompson wrote:
> > On Wed, 2019-08-21 at 17:15 -0400, stan wrote:
> > > [EXTERNAL SOURCE]
> > >
> > >
> > >
> > > I have a situation where we need to import data, as an interim measure,
> > > from spreadsheets.
> > >
> > > I have read up on \copy and COPY, but I do not see that either of these can
> > > use the header from a CSV file to define a new table. Am I missing
> > > something?
> > >
> > > Also downloaded something called pgfutter, which I thought would do this,
> > > but have not had any success with this. After I (thought) I had figured out
> > > the arguments, it just seams to hag forever.
> > >
> > >
> > > --
> > > "They that would give up essential liberty for temporary safety deserve
> > > neither liberty nor safety."
> > > -- Benjamin Franklin
> > >
> > >
> >
> > https://csvkit.readthedocs.io/en/latest/tutorial/3_power_tools.html#csvsql-and-sql2csv-ultimate-powe...
> >
> > csvsql and sql2csv: ultimate power
> > ...snip...
> > By default, csvsql will generate a create table statement for your data. You can specify what sort of database you are using with the -i flag:
> > ...snip...
> >
>
> Example
>
> https://stackoverflow.com/questions/35243432/how-to-generate-a-schema-from-a-csv-for-a-postgresql-co...
>
a more detailed example
https://archive.is/pFpJi
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Importing from CSV, auto creating table?
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
@ 2019-08-23 10:16 ` Steve Atkins <steve@blighty.com>
4 siblings, 0 replies; 9+ messages in thread
From: Steve Atkins @ 2019-08-23 10:16 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 21/08/2019 22:15, stan wrote:
> I have a situation where we need to import data, as an interim measure,
> from spreadsheets.
>
> I have read up on \copy and COPY, but I do not see that either of these can
> use the header from a CSV file to define a new table. Am I missing
> something?
>
> Also downloaded something called pgfutter, which I thought would do this,
> but have not had any success with this. After I (thought) I had figured out
> the arguments, it just seams to hag forever.
>
You might find https://github.com/wttw/csvpg useful. It creates tables
with column names based on the CSV header, and data types intuited from
the data.
(The only pre-built binary there is for Mac right now; I should at least
add one for Windows).
Cheers,
Steve
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2019-08-23 10:16 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21 21:15 Importing from CSV, auto creating table? stan <stanb@panix.com>
2019-08-21 21:25 ` David G. Johnston <david.g.johnston@gmail.com>
2019-08-21 22:45 ` DiasCosta <diascosta@diascosta.org>
2019-08-22 02:36 ` Ron <ronljohnsonjr@gmail.com>
2019-08-22 03:14 ` David G. Johnston <david.g.johnston@gmail.com>
2019-08-22 12:25 ` Reid Thompson <Reid.Thompson@omnicell.com>
2019-08-22 13:01 ` Reid Thompson <Reid.Thompson@omnicell.com>
2019-08-22 13:14 ` Reid Thompson <Reid.Thompson@omnicell.com>
2019-08-23 10:16 ` Steve Atkins <steve@blighty.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox