title: PostgreSQL COPY FROM csv - csv formating issues
body: <p>I have a csv file that I'm trying to import into my PostgreSQL database (v.10). I'm using the following basic SQL syntax:</p>
  
  <pre><code>COPY table (col_1, col_2, col_3)
  FROM '/filename.csv'
  DELIMITER ',' CSV HEADER
  QUOTE '"'
  ESCAPE '\';
  </code></pre>
  
  <p>First 30,000 lines or so are imported without any problem. But then I start bumping into formatting issues in the csv file that break the import:</p>
  
  <ul>
  <li>Double quotes in double quotes: "value_1",<strong>""value_2""</strong>,"value_3" or "value_1",<strong>"val"ue_2"</strong>,"value_3"</li>
  </ul>
  
  <p>The typical error I get is</p>
  
  <pre><code>ERROR: extra data after last expected column
  </code></pre>
  
  <p>So I started editing the csv file manually using Vim (the csv file has close to 7 million lines so can't really think of another desktop tool to use)</p>
  
  <ul>
  <li>Is there anything I can do with my SQL syntax to handle those malformed strings? Using alternative ESCAPE clauses? Using regex?</li>
  <li>Can you think of a way to handle those formatting issues in Vim or using another tool or function?</li>
  </ul>
  
  <p>Thanks a lot!</p>