Skip to content
Advertisement

Problem with COPY FROM with PHP in postgresql

I have some big .csv files and I am trying to put it into database. I am using this construction:

COPY table_name(column1, column2, column..., columnN) FROM stdin;
column1 column2 column... column N
column1 column2 column... column N
column1 column2 column... column N
column1 column2 column... column N
.

But after use i function in CLI I got that:

ERROR:  end-of-copy marker corrupt

This is not a problem with end marker, but with encoding. If I open this file in VIM and will save it again, everything is OK, but without this operations I got this error all the time. What can I do in PHP (with PHP I create those files) to fix that? If this is for sure problem with encoding?

Advertisement

Answer

Is there also a newline after the . ? Check the example in the PHP-manual for pg_put_line() as well and take notice of the n at the end.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement