dbTalk Databases Forums  

[BUGS] CSV import issue - please help

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] CSV import issue - please help in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bernard
 
Posts: n/a

Default [BUGS] CSV import issue - please help - 08-20-2005 , 09:39 PM






Dear Postgresql specialists

I would like to seek help with problems I am experiencing with the
COPY command.

We have a user whose 3rd party software exports text data in CSV
format.

The Postgresql import function COPY supports CSV but fails when
importing the data.

I have studied in the Postgresql documentation the specification for
CSV input of the COPY command and found that the data is compliant
with that specification.

In particular, I could confirm that the data uses the same newline
character "\n" for both CSV record termination and new lines within
text.

To eliminate any misunderstandings, I have executed a testcase on
Linux, again exclusively using the Linux "\n" newline character as
follows:


# su postgres
$ psql -d myDB -U postgres
=3D# CREATE TABLE TEST(FIELD_1 TEXT NOT NULL);
=3D# INSERT INTO TEST(FIELD_1)VALUES('Hello1 \n\n');
=3D# INSERT INTO TEST(FIELD_1)VALUES('Hello2');
=3D# COPY TEST TO '/tmp/TEST.txt' DELIMITER '\t' CSV;

WARNING: CSV fields with embedded linefeed or carriage return
characters might not be able to be reimported

=3D# DELETE FROM TEST;
DELETE 2
=3D# COPY TEST FROM '/tmp/TEST.txt' DELIMITER '\t' CSV;
ERROR: unterminated CSV quoted field
CONTEXT: COPY test, line 2: ""


The error messages in the tescase suggest that the implementation does
not agree with the specification in the manual.

I have also verified with other tests that the user's CSV output
conforms with the Postgres specification.

Possibly someone with more in-depth knowledge may have additional
information, e.g. undocumented command parameters, that circumvent
this problem.

The user has only a CSV export function available without any option
to eliminate newline characters from that data.

Unfortunately the user is not in the position to convert the output to
another format or change the software output in any non-standard way.

Any help would be highly appreciated.

Regards

Bernard

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.