Beispiel CSV-Zeile:postgresql COPY und CSV-Daten w/doppelte Anführungszeichen
"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"
Alle Werte nach "First" sind numerische Spalten. Viele NULL-Werte als solche zitiert, richtig.
Versuch COPY:
copy mytable from 'myfile.csv' with csv header quote '"';
NOPE: ERROR: invalid input syntax for type numeric: ""
Nun, ja. Es ist ein Nullwert. Versuch 2 bei COPY:
copy mytable from 'myfile.csv' with csv header quote '"' null '""';
NOPE: ERROR: CSV quote character must not appear in the NULL specification
Was ist ein Kerl zu tun? Entfernen Sie alle doppelten Anführungszeichen aus der Datei, bevor Sie COPY
ausführen? Kann das tun, aber ich dachte mir, es gibt eine richtige Lösung für das, was ein unglaublich häufiges Problem sein muss.
Sieht aus wie ein Fehler in PostgreSQL mir (was in 9.4 noch da ist), weil 'null‚‘' sollte leer behandeln Zeichenfolgen als null. – Tobia