Re: Import csv to temp table

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>, arun chirappurath <arunsnmimt(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Import csv to temp table
Date: 2024-01-02 16:06:23
Message-ID: 84b1254f-b409-44b8-a2cf-d5e4c0e8d828@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2024-01-02 16:09:22 Re: New SET privilege for pg_has_role() in v16+
Previous Message Dominique Devienne 2024-01-02 15:24:45 New SET privilege for pg_has_role() in v16+