What is the correct syntax for text arrays and hstore values in a CSV/TSV file for import into Postgres using "Import Data from File..."?


I've tried every combination of braces, parens, double quotes, escaped double quotes, etc. that I can think of, but I keep getting multiple errors that look like this:

5:1: ERROR: Syntax error near ',' at position 70
6:1: ERROR: malformed array literal: "" Detail: Array value must start with "{" or dimension information.

Currently, my text array values look like this: {\"foo\",\"bar\",\"baz\",\"qux\"}

And my hstore values look like this: {"\"foo\" => \"bar\"","\"baz\" => \"qux\""}

I'm looking for the syntax for how these values should appear in individual cells of a Google Sheet spreadsheet, which I then download in TSV form and attempt to load using the "Import Data from File..." command by right-clicking on the appropriate database table in the database editor.

1 comment

After much trial and error, I finally have the data importing properly. If you are interested in the proper syntax for importing the way that I am without error, I posted what worked for me here: https://stackoverflow.com/questions/69847184/how-do-i-format-text-array-and-hstore-data-in-a-csv-tsv-file-for-importing-into/69859804#69859804 


Please sign in to leave a comment.