I have a large text file that has one column per row and I want to import this data file into Postgres.
I have a working MySQL script.
LOAD DATA LOCAL
INFILE '/Users/Farmor/data.sql'
INTO TABLE tablename
COLUMNS TERMINATED BY '\n';
How can I translate this into Postgres? I've tried amongst other this command.
COPY tablename
FROM '/Users/Farmor/data.sql'
WITH DELIMITER '\n'
However it complains:
ERROR: COPY delimiter must be a single one-byte character
'\n'is a two character string (depending on string settings and PostgreSQL version), you want to sayE'\n'to get a newline. But that will probably get you a "COPY delimiter cannot be newline or carriage return" error as PostgreSQL won't be able to tell the difference between columns and rows if they both use the same delimiter. I'd guess that you're going to have to mangle your data file into some other layout (possibly even by loading it into MySQL and then dumping it from there to SQL or CSV).