top | item 32746047

(no title)

nardi | 3 years ago

Do NOT read a CSV file by splitting on commas. Python has a perfect CSV library built right in: https://docs.python.org/3/library/csv.html.

If you split on commas, your code will fail for quoted fields with commas in them.

discuss

order

orangepurple|3 years ago

This is obviously a quick and dirty hack. It only splits the header by commas. Postgres has its own read in logic you can adjust by passing arguments to \copy or copy. If you have anything more complex you need to handle it by parsing the header more intelligently than splitting on commas and adding appropriate arguments to copy or \copy