1
votes

I have the three statements below that all work until it hits a row with an extra tab at the end of the tab delimited text file that I am trying to import. Any way to tell Postgres to ignore extra tabs?

copy mara FROM 'c:/Postgres MME/AG00_MARA.txt' DELIMITER E'\t' NULL '' CSV HEADER;

copy mara FROM 'c:/Postgres MME/AG00_MARA.txt' DELIMITER E'\t' CSV HEADER;

copy mara FROM 'c:/Postgres MME/AG00_MARA.txt' WITH (FORMAT csv, DELIMITER E'\t', NULL '', HEADER);

Image of Notepad++ Where I see the extra tab at the end of the row

1

1 Answers

1
votes

Don't try to ignore it, just fix your data by removing all the trailing tabs with regex \t$. For example in Linux:

sed -i 's/\t$//g' AG00_MARA.txt