I used csvsql to generate CREATE statements, and it looks like it assumed trimmed fields though the data has some spaces padding the field:
ERROR: value too long for type character varying(11)
CONTEXT: COPY example, line 1314, column state: " South Korea"
I'm not entirely sure why the data has padding -- it definitely shouldn't but about half the values in the state column have some padding around them.
I could use ALTER
to make more space in the field, and then UPDATE example SET state=trim(state);
after I COPY
the csv in, I'm wondering if there's a clean way to just trim the padding as I import the data?
--skipinitialspace
help? Also, I'd just pick theCREATE
statements, adjust them to my needs (for example, one could remove the limit fromvarchar
- see the tip under postgresql.org/docs/10/static/datatype-character.html) and then just copy the data (not fully sure how it's done withcsvsql
).--skipinitialspace
doesn't help, unfortunately.