例CSV行:PostgreSQL的COPY和CSV數據瓦特/雙引號
"2012","Test User","ABC","First","71.0","","","0","0","3","3","0","0","","0","","","","","0.1","","4.0","0.1","4.2","80.8","847"
所有值之後 「第一」 是數字列。剛剛引用的很多NULL值是正確的。
在嘗試COPY:
copy mytable from 'myfile.csv' with csv header quote '"';
NOPE:ERROR: invalid input syntax for type numeric: ""
嗯,是的。這是一個空值。在COPY嘗試2:
copy mytable from 'myfile.csv' with csv header quote '"' null '""';
NOPE:ERROR: CSV quote character must not appear in the NULL specification
什麼是小夥子呢?在運行COPY
之前,從文件中去除所有雙引號?可以做到這一點,但我認爲有一個適當的解決方案必須是一個非常普遍的問題。
貌似PostgreSQL中給我的錯誤(這是仍然存在在9.4),因爲'空「」'應該把空字符串爲空。 – Tobia 2016-03-14 10:57:29