pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Daniel Verite <daniel@manitou-mail.org>
To: arun chirappurath <arunsnmimt@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Import csv to temp table
Date: Tue, 2 Jan 2024 08:06:23 -0800
Message-ID: <84b1254f-b409-44b8-a2cf-d5e4c0e8d828@aklaver.com> (raw)
In-Reply-To: <369a8ac6-e77d-4de6-878a-01eee781acaf@manitou-mail.org>
References: <369a8ac6-e77d-4de6-878a-01eee781acaf@manitou-mail.org>

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.DataF...) 
to pull from a CSV into a table.


> 
> 
> Best regards,

-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (7+ messages)  latest in thread

Message-ID: <84b1254f-b409-44b8-a2cf-d5e4c0e8d828@aklaver.com>
Permalink:  ../84b1254f-b409-44b8-a2cf-d5e4c0e8d828@aklaver.com/
Also on:    postgresql.org/message-id/84b1254f-b409-44b8-a2cf-d5e4c0e8d828@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, daniel@manitou-mail.org, arunsnmimt@gmail.com
  Subject: Re: Import csv to temp table
  In-Reply-To: <84b1254f-b409-44b8-a2cf-d5e4c0e8d828@aklaver.com>
  References: <369a8ac6-e77d-4de6-878a-01eee781acaf@manitou-mail.org> <84b1254f-b409-44b8-a2cf-d5e4c0e8d828@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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