pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feeddelimeters psql /CSV
3+ messages / 3 participants
[nested] [flat]
* delimeters psql /CSV
@ 2019-06-07 10:01 paul.malm@lfv.se
2019-06-07 11:24 ` Re: delimeters psql /CSV Ron <ronljohnsonjr@gmail.com>
2019-06-07 12:02 ` Re: delimeters psql /CSV Daniel Verite <daniel@manitou-mail.org>
0 siblings, 2 replies; 3+ messages in thread
From: paul.malm@lfv.se @ 2019-06-07 10:01 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi, I have a problem with psql and CSV.
C:\Users\an\bin>C:\Tmp\psql -h 10.211.43.22 -p 5432 -U postgres -d aatest -w -c "\copy public.""Bayern"" FROM 'C:\Users\an\test\Bayern.csv' WITH DELIMITER ';' CSV"
Error: extra data after expected last column
CONTEXT: COPY Bayern, row 1: "48.455555555555556;11.800833333333333;Anglberg/Amper;Industrial plant;722;220;220;2133;0;0;Undefined..."
I have a table (Bayern) with all columns in the right format. There is a column-value which has a '/' in the string (Anglberg/Amper). I think that '/' is taken for a delimeter, since when I replace / with 'white space' it works.
I use ';' as delimeter. I have UTF-8 encoding in the db. Is there a way around this or do I have to go through all csv files and change '/' to white space?
Kind regards,
Paul
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: delimeters psql /CSV
2019-06-07 10:01 delimeters psql /CSV paul.malm@lfv.se
@ 2019-06-07 11:24 ` Ron <ronljohnsonjr@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Ron @ 2019-06-07 11:24 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 6/7/19 5:01 AM, paul.malm@lfv.se wrote:
>
> Hi, I have a problem with psql and CSV.
>
> C:\Users\an\bin>C:\Tmp\psql -h 10.211.43.22 -p 5432 -U postgres -d aatest
> -w -c "\copy public.""Bayern"" FROM 'C:\Users\an\test\Bayern.csv' WITH
> DELIMITER ';' CSV"
>
> Error: extra data after expected last column
>
> CONTEXT: COPY Bayern, row 1:
> "48.455555555555556;11.800833333333333;Anglberg/Amper;Industrial
> plant;722;220;220;2133;0;0;Undefined..."
>
> I have a table (Bayern) with all columns in the right format. There is a
> column-value which has a ‘/’ in the string (Anglberg/Amper). I think that
> ‘/’ is taken for a delimeter, since when I replace / with ‘white space‘ it
> works.
>
> I use ‘;’ as delimeter. I have UTF-8 encoding in the db. Is there a way
> around this or do I have to go through all csv files and change ‘/’ to
> white space?
>
What if you escape the slashes with backslashes?
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: delimeters psql /CSV
2019-06-07 10:01 delimeters psql /CSV paul.malm@lfv.se
@ 2019-06-07 12:02 ` Daniel Verite <daniel@manitou-mail.org>
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Verite @ 2019-06-07 12:02 UTC (permalink / raw)
To: paul.malm@lfv.se; +Cc: pgsql-general@lists.postgresql.org
Paul Malm wrote:
> C:\Users\an\bin>C:\Tmp\psql -h 10.211.43.22 -p 5432 -U postgres -d aatest -w
> -c "\copy public.""Bayern"" FROM 'C:\Users\an\test\Bayern.csv' WITH
> DELIMITER ';' CSV"
> Error: extra data after expected last column
> CONTEXT: COPY Bayern, row 1:
> "48.455555555555556;11.800833333333333;Anglberg/Amper;Industrial
> plant;722;220;220;2133;0;0;Undefined..."
>
> I have a table (Bayern) with all columns in the right format. There is a
> column-value which has a '/' in the string (Anglberg/Amper). I think that
> '/' is taken for a delimeter, since when I replace / with 'white space' it
> works.
There's no reason for '/' to be taken as a delimiter.
Can you can share the table definition and the offending line as an
attachment, so that someone can try to reproduce this with the
exact same data?
Also mention your PostgreSQL version and the shell the command
is invoked from (cmd.exe, powershell, something else?) just in case
it matters.
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2019-06-07 12:02 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07 10:01 delimeters psql /CSV paul.malm@lfv.se
2019-06-07 11:24 ` Ron <ronljohnsonjr@gmail.com>
2019-06-07 12:02 ` Daniel Verite <daniel@manitou-mail.org>
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