pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feed(no subject)
6+ messages / 5 participants
[nested] [flat]
* (no subject)
@ 2019-07-02 07:39 Prakash Ramakrishnan <prakash.ramakrishnan.ap@nielsen.com>
0 siblings, 1 reply; 6+ messages in thread
From: Prakash Ramakrishnan @ 2019-07-02 07:39 UTC (permalink / raw)
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Hi Team,
We are getting below error while during import the csv file please do the
needful.
CREATE TABLE ujshjk ( pod_id bigint NOT NULL, src_id smallint, eff_strt_dt
date,eff_end_dt date,ins_dt timestamp without time zone,updt_dt timestamp
without time zone,nat_key_1 character(50),nat_key_2 character(50),nat_key_3
character(50),nat_key_4 character(50),nat_key_5 character(50));
-bash-4.2$ more ckr_sto.csv
4937880 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
| | 5000128790679 | | | |
4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
| | 5000128639345 | | | |
4939744 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
| | 5000128684510 | | | |
4939750 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
| | 5000128683100 | | | |
4936360 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
| | 5000128567527 | | | |
4940308 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
| | 5000128781329 | | | |
4938006 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
| | 4000128912554 | | | |
4937457 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
| | 5000128426574 | | | |
error
----------
postgres=# \copy ckr_sto from /data/ckr_sto.csv CSV HEADER;
ERROR: invalid input syntax for integer: " 4939355 | 12 | 2015-01-05
| | 2015-01-05 05:51:47 | | | 5000128639345 |
| | | "
CONTEXT: COPY ckr_sto, line 2, column pod_id: " 4939355 | 12 |
2015-01-05 | | 2015-01-05 05:51:47 | | |
500012863934..."
postgres=#
postgres=#
--
Thanks,
Prakash.R
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re:
@ 2019-07-02 07:45 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Prakash Ramakrishnan <prakash.ramakrishnan.ap@nielsen.com>
0 siblings, 2 replies; 6+ messages in thread
From: Laurenz Albe @ 2019-07-02 07:45 UTC (permalink / raw)
To: Prakash Ramakrishnan <prakash.ramakrishnan.ap@nielsen.com>; pgsql-general@lists.postgresql.org
On Tue, 2019-07-02 at 13:09 +0530, Prakash Ramakrishnan wrote:
> We are getting below error while during import the csv file please do the needful.
I'd say the needful thing here is for you to read the documentation...
> -bash-4.2$ more ckr_sto.csv
> 4937880 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128790679 | | | |
> 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128639345 | | | |
> 4939744 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128684510 | | | |
> 4939750 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128683100 | | | |
> 4936360 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128567527 | | | |
> 4940308 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128781329 | | | |
> 4938006 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 4000128912554 | | | |
> 4937457 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128426574 | | | |
>
> error
> ----------
> postgres=# \copy ckr_sto from /data/ckr_sto.csv CSV HEADER;
> ERROR: invalid input syntax for integer: " 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128639345 | | | | "
> CONTEXT: COPY ckr_sto, line 2, column pod_id: " 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 500012863934..."
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re:
@ 2019-07-02 08:02 Prakash Ramakrishnan <prakash.ramakrishnan.ap@nielsen.com>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
1 sibling, 0 replies; 6+ messages in thread
From: Prakash Ramakrishnan @ 2019-07-02 08:02 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Thanks a lot. I will check and let you know.
Regards,
Prakash.R
On Tue, Jul 2, 2019 at 1:15 PM Laurenz Albe <laurenz.albe@cybertec.at>
wrote:
> On Tue, 2019-07-02 at 13:09 +0530, Prakash Ramakrishnan wrote:
> > We are getting below error while during import the csv file please do
> the needful.
>
> I'd say the needful thing here is for you to read the documentation...
>
> > -bash-4.2$ more ckr_sto.csv
> > 4937880 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128790679 | | | |
> > 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128639345 | | | |
> > 4939744 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128684510 | | | |
> > 4939750 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128683100 | | | |
> > 4936360 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128567527 | | | |
> > 4940308 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128781329 | | | |
> > 4938006 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 4000128912554 | | | |
> > 4937457 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128426574 | | | |
> >
> > error
> > ----------
> > postgres=# \copy ckr_sto from /data/ckr_sto.csv CSV HEADER;
> > ERROR: invalid input syntax for integer: " 4939355 | 12 |
> 2015-01-05 | | 2015-01-05 05:51:47 | | |
> 5000128639345 | | | | "
> > CONTEXT: COPY ckr_sto, line 2, column pod_id: " 4939355 | 12 |
> 2015-01-05 | | 2015-01-05 05:51:47 | | |
> 500012863934..."
>
> From the documentation of COPY:
>
> DELIMITER
>
> Specifies the character that separates columns within each row (line)
> of the file.
> The default is a tab character in text format, a comma in CSV format.
> This must be a single one-byte character. This option is not allowed
> when using binary format.
>
> Yours,
> Laurenz Albe
> --
> Cybertec | https://www.cybertec-postgresql.com
>
>
--
Thanks,
Prakash.R
PostgreSQL - Offshore DBA support TCS / Nielsen Infrastructure Team On call
: +91-8939599426
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re:
@ 2019-07-02 23:04 raf@raf.org
parent: Laurenz Albe <laurenz.albe@cybertec.at>
1 sibling, 1 reply; 6+ messages in thread
From: raf@raf.org @ 2019-07-02 23:04 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Laurenz Albe wrote:
> On Tue, 2019-07-02 at 13:09 +0530, Prakash Ramakrishnan wrote:
> > We are getting below error while during import the csv file please do the needful.
>
> I'd say the needful thing here is for you to read the documentation...
>
> > -bash-4.2$ more ckr_sto.csv
> > 4937880 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128790679 | | | |
> > 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128639345 | | | |
> > 4939744 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128684510 | | | |
> > 4939750 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128683100 | | | |
> > 4936360 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128567527 | | | |
> > 4940308 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128781329 | | | |
> > 4938006 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 4000128912554 | | | |
> > 4937457 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128426574 | | | |
> >
> > error
> > ----------
> > postgres=# \copy ckr_sto from /data/ckr_sto.csv CSV HEADER;
> > ERROR: invalid input syntax for integer: " 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128639345 | | | | "
> > CONTEXT: COPY ckr_sto, line 2, column pod_id: " 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 500012863934..."
>
> >From the documentation of COPY:
>
> DELIMITER
>
> Specifies the character that separates columns within each row (line) of the file.
> The default is a tab character in text format, a comma in CSV format.
> This must be a single one-byte character. This option is not allowed when using binary format.
>
> Yours,
> Laurenz Albe
> --
> Cybertec | https://www.cybertec-postgresql.com
in other words, ckr_sto.csv is not a csv file.
it just has .csv at the end of its name.
that's why psql tried to interpret the entire
line as the first column: there were no commas.
its contents should look something like:
4937880,12,2015-01-05,,2015-01-05 05:51:47,,,5000128790679,,,,
4939355,12,2015-01-05,,2015-01-05 05:51:47,,,5000128639345,,,,
4939744,12,2015-01-05,,2015-01-05 05:51:47,,,5000128684510,,,,
4939750,12,2015-01-05,,2015-01-05 05:51:47,,,5000128683100,,,,
4936360,12,2015-01-05,,2015-01-05 05:51:47,,,5000128567527,,,,
4940308,12,2015-01-05,,2015-01-05 05:51:47,,,5000128781329,,,,
4938006,12,2015-01-05,,2015-01-05 05:51:47,,,4000128912554,,,,
4937457,12,2015-01-05,,2015-01-05 05:51:47,,,5000128426574,,,,
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re:
@ 2019-07-02 23:08 Andrew Kerber <andrew.kerber@gmail.com>
parent: raf@raf.org
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Kerber @ 2019-07-02 23:08 UTC (permalink / raw)
To: raf@raf.org; +Cc: pgsql-general@lists.postgresql.org
Yes, CSV stands for comma separated variable length. This means that the
fields in each row should be separated by commas, with a carriage return at
the end of each record. You have a file using | separators, which mean it
is not csv.
On Tue, Jul 2, 2019 at 6:04 PM <raf@raf.org> wrote:
> Laurenz Albe wrote:
>
> > On Tue, 2019-07-02 at 13:09 +0530, Prakash Ramakrishnan wrote:
> > > We are getting below error while during import the csv file please do
> the needful.
> >
> > I'd say the needful thing here is for you to read the documentation...
> >
> > > -bash-4.2$ more ckr_sto.csv
> > > 4937880 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128790679 | | | |
> > > 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128639345 | | | |
> > > 4939744 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128684510 | | | |
> > > 4939750 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128683100 | | | |
> > > 4936360 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128567527 | | | |
> > > 4940308 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128781329 | | | |
> > > 4938006 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 4000128912554 | | | |
> > > 4937457 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 |
> | | 5000128426574 | | | |
> > >
> > > error
> > > ----------
> > > postgres=# \copy ckr_sto from /data/ckr_sto.csv CSV HEADER;
> > > ERROR: invalid input syntax for integer: " 4939355 | 12 |
> 2015-01-05 | | 2015-01-05 05:51:47 | | |
> 5000128639345 | | | | "
> > > CONTEXT: COPY ckr_sto, line 2, column pod_id: " 4939355 | 12 |
> 2015-01-05 | | 2015-01-05 05:51:47 | | |
> 500012863934..."
> >
> > >From the documentation of COPY:
> >
> > DELIMITER
> >
> > Specifies the character that separates columns within each row
> (line) of the file.
> > The default is a tab character in text format, a comma in CSV format.
> > This must be a single one-byte character. This option is not allowed
> when using binary format.
> >
> > Yours,
> > Laurenz Albe
> > --
> > Cybertec | https://www.cybertec-postgresql.com
>
> in other words, ckr_sto.csv is not a csv file.
> it just has .csv at the end of its name.
> that's why psql tried to interpret the entire
> line as the first column: there were no commas.
>
> its contents should look something like:
>
> 4937880,12,2015-01-05,,2015-01-05 05:51:47,,,5000128790679,,,,
> 4939355,12,2015-01-05,,2015-01-05 05:51:47,,,5000128639345,,,,
> 4939744,12,2015-01-05,,2015-01-05 05:51:47,,,5000128684510,,,,
> 4939750,12,2015-01-05,,2015-01-05 05:51:47,,,5000128683100,,,,
> 4936360,12,2015-01-05,,2015-01-05 05:51:47,,,5000128567527,,,,
> 4940308,12,2015-01-05,,2015-01-05 05:51:47,,,5000128781329,,,,
> 4938006,12,2015-01-05,,2015-01-05 05:51:47,,,4000128912554,,,,
> 4937457,12,2015-01-05,,2015-01-05 05:51:47,,,5000128426574,,,,
>
>
>
>
--
Andrew W. Kerber
'If at first you dont succeed, dont take up skydiving.'
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re:
@ 2019-07-02 23:14 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Andrew Kerber <andrew.kerber@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Adrian Klaver @ 2019-07-02 23:14 UTC (permalink / raw)
To: Andrew Kerber <andrew.kerber@gmail.com>; raf@raf.org; +Cc: pgsql-general@lists.postgresql.org
On 7/2/19 4:08 PM, Andrew Kerber wrote:
> Yes, CSV stands for comma separated variable length. This means that
CSV = Comma Separated Values
> the fields in each row should be separated by commas, with a carriage
> return at the end of each record. You have a file using | separators,
> which mean it is not csv.
That is not strictly true:
https://en.wikipedia.org/wiki/Comma-separated_values
And is definitely not true for this context, using Postgres COPY:
https://www.postgresql.org/docs/9.6/sql-copy.html
"CSV Format
This format option is used for importing and exporting the Comma
Separated Value (CSV) file format used by many other programs, such as
spreadsheets. Instead of the escaping rules used by PostgreSQL's
standard text format, it produces and recognizes the common CSV escaping
mechanism.
The values in each record are separated by the DELIMITER character. If
the value contains the delimiter character, the QUOTE character, the
NULL string, a carriage return, or line feed character, then the whole
value is prefixed and suffixed by the QUOTE character, and any
occurrence within the value of a QUOTE character or the ESCAPE character
is preceded by the escape character. You can also use FORCE_QUOTE to
force quotes when outputting non-NULL values in specific columns.
...
"
You do have to specify the delimiter if it is not the default comma. In
the OP's case the delimiter would need to be set to '|'.
>
> On Tue, Jul 2, 2019 at 6:04 PM <raf@raf.org <mailto:raf@raf.org>> wrote:
>
> Laurenz Albe wrote:
>
> > On Tue, 2019-07-02 at 13:09 +0530, Prakash Ramakrishnan wrote:
> > > We are getting below error while during import the csv file
> please do the needful.
> >
> > I'd say the needful thing here is for you to read the
> documentation...
> >
> > > -bash-4.2$ more ckr_sto.csv
> > > 4937880 | 12 | 2015-01-05 | | 2015-01-05
> 05:51:47 | | | 5000128790679 | |
> | |
> > > 4939355 | 12 | 2015-01-05 | | 2015-01-05
> 05:51:47 | | | 5000128639345 | |
> | |
> > > 4939744 | 12 | 2015-01-05 | | 2015-01-05
> 05:51:47 | | | 5000128684510 | |
> | |
> > > 4939750 | 12 | 2015-01-05 | | 2015-01-05
> 05:51:47 | | | 5000128683100 | |
> | |
> > > 4936360 | 12 | 2015-01-05 | | 2015-01-05
> 05:51:47 | | | 5000128567527 | |
> | |
> > > 4940308 | 12 | 2015-01-05 | | 2015-01-05
> 05:51:47 | | | 5000128781329 | |
> | |
> > > 4938006 | 12 | 2015-01-05 | | 2015-01-05
> 05:51:47 | | | 4000128912554 | |
> | |
> > > 4937457 | 12 | 2015-01-05 | | 2015-01-05
> 05:51:47 | | | 5000128426574 | |
> | |
> > >
> > > error
> > > ----------
> > > postgres=# \copy ckr_sto from /data/ckr_sto.csv CSV HEADER;
> > > ERROR: invalid input syntax for integer: " 4939355 | 12 |
> 2015-01-05 | | 2015-01-05 05:51:47 | | |
> 5000128639345 | | | | "
> > > CONTEXT: COPY ckr_sto, line 2, column pod_id: " 4939355 |
> 12 | 2015-01-05 | | 2015-01-05 05:51:47 | |
> | 500012863934..."
> >
> > >From the documentation of COPY:
> >
> > DELIMITER
> >
> > Specifies the character that separates columns within each
> row (line) of the file.
> > The default is a tab character in text format, a comma in CSV
> format.
> > This must be a single one-byte character. This option is not
> allowed when using binary format.
> >
> > Yours,
> > Laurenz Albe
> > --
> > Cybertec | https://www.cybertec-postgresql.com
>
> in other words, ckr_sto.csv is not a csv file.
> it just has .csv at the end of its name.
> that's why psql tried to interpret the entire
> line as the first column: there were no commas.
>
> its contents should look something like:
>
> 4937880,12,2015-01-05,,2015-01-05 05:51:47,,,5000128790679,,,,
> 4939355,12,2015-01-05,,2015-01-05 05:51:47,,,5000128639345,,,,
> 4939744,12,2015-01-05,,2015-01-05 05:51:47,,,5000128684510,,,,
> 4939750,12,2015-01-05,,2015-01-05 05:51:47,,,5000128683100,,,,
> 4936360,12,2015-01-05,,2015-01-05 05:51:47,,,5000128567527,,,,
> 4940308,12,2015-01-05,,2015-01-05 05:51:47,,,5000128781329,,,,
> 4938006,12,2015-01-05,,2015-01-05 05:51:47,,,4000128912554,,,,
> 4937457,12,2015-01-05,,2015-01-05 05:51:47,,,5000128426574,,,,
>
>
>
>
>
> --
> Andrew W. Kerber
>
> 'If at first you dont succeed, dont take up skydiving.'
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2019-07-02 23:14 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 07:39 Prakash Ramakrishnan <prakash.ramakrishnan.ap@nielsen.com>
2019-07-02 07:45 ` Re: Laurenz Albe <laurenz.albe@cybertec.at>
2019-07-02 08:02 ` Re: Prakash Ramakrishnan <prakash.ramakrishnan.ap@nielsen.com>
2019-07-02 23:04 ` Re: raf@raf.org
2019-07-02 23:08 ` Re: Andrew Kerber <andrew.kerber@gmail.com>
2019-07-02 23:14 ` Re: Adrian Klaver <adrian.klaver@aklaver.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