PG COPY error: invalid input syntax for integer

前端 未结 12 1823
走了就别回头了
走了就别回头了 2020-12-29 01:02

Running COPY results in ERROR: invalid input syntax for integer: \"\" error message for me. What am I missing?

My /tmp/people.cs

12条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 01:38

    Ended up doing this using csvfix:

    csvfix map -fv '' -tv '0' /tmp/people.csv > /tmp/people_fixed.csv
    

    In case you know for sure which columns were meant to be integer or float, you can specify just them:

    csvfix map -f 1 -fv '' -tv '0' /tmp/people.csv > /tmp/people_fixed.csv
    

    Without specifying the exact columns, one may experience an obvious side-effect, where a blank string will be turned into a string with a 0 character.

提交回复
热议问题