Re: Import csv to temp table - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Import csv to temp table
Date
Msg-id 84b1254f-b409-44b8-a2cf-d5e4c0e8d828@aklaver.com
Whole thread Raw
In response to Re: Import csv to temp table  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-general
On 1/2/24 06:51, Daniel Verite wrote:
>     arun chirappurath wrote:
> 
>> Do we have any scripts that create a temp table with column names
>> from the first row of csv files?
> 
> csvkit [1] does that.
> 
> [1] https://csvkit.readthedocs.io/en/latest/

In addition to the above which I have used you might want to take a look at:

Polars
https://pola.rs/

and

Duckdb
https://duckdb.org/

They both allow you to query CSV(and other format) files directly. I 
have found them very useful for looking at CSV files and you can 
transfer data elsewhere later.

Then there is:

Pandas
https://pandas.pydata.org/pandas-docs/stable/index.html

which has 
read_csv(https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html) 
and 
to_sql(https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_sql.html#pandas.DataFrame.to_sql)

to pull from a CSV into a table.


> 
> 
> Best regards,

-- 
Adrian Klaver
adrian.klaver@aklaver.com




pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: New SET privilege for pg_has_role() in v16+
Next
From: Adrian Klaver
Date:
Subject: Re: New SET privilege for pg_has_role() in v16+