Search Postgresql Archives

Re:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx> 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.'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux