gpt4 book ai didi

postgresql - Postgres : copy errors when extra tab on tab delimited text file

转载 作者:行者123 更新时间:2023-11-29 13:21:59 25 4
gpt4 key购买 nike

我有以下三个语句,它们都有效,直到它在我尝试导入的制表符分隔文本文件的末尾遇到一个带有额外制表符的行。有什么方法可以告诉 Postgres 忽略额外的标签?

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;

复制 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

最佳答案

不要试图忽略它,只需使用正则表达式 \t$ 删除所有尾随制表符来修复您的数据。例如在 Linux 中:

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

关于postgresql - Postgres : copy errors when extra tab on tab delimited text file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40116125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com