postgresql - Postgres COPY command - fields with commas, quoted with double quotes -


I searched and searched for some posts related to postgre CSV import, but nothing that resolves my current problem is.

I use the postgres copy command at all times to bring data from second source data sources to the current 100 million row Conflicts with CCV file, comma-delimited . The problem is with so many rows:

  009098,0981098094, "something", "something else", "" this one, okay, there is a problem, "one more thing"   

Fields enclosed in double quotes with embedded commas. Fields are not correctly parsed and I get an error:

  "Error: additional data after the last expected column"   

Generally when these I get ridiculous rows ad hoc, but this file is so big that I'm hoping to defend it from something else in a normal way. There is not a possibility to ask for a modified data format.

  '/path/to/file.csv' csv header quote '' 'for example    

This is distorted CSV.

has three values:

  • is "pancakes"
  • Home

    The line you are having trouble with, repeats the double values:

      009098,0981098094, "something", "something else", "" this one, okay, there is a problem "" another thing "^^ ^^   

    me It does not appear that anything in it can be as clear as the correct version is ambiguous: should it be "it should be one, ok, a problem" or is it "" Is okay The problem is "" "?

    I think you have to fix it by hand. A quick sed one-liner If you have a specific type of broken line , Then he should be able to work with it.


    For reference purposes, I have seen the closest thing to the CSV standard and in section 2 it is to say:

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -