Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://www.postgresql.org/docs/current/interactive/sql-copy.html" rel="nofollow">Per documentation</a> on the <code>COPY</code> statement, it should be <code>WITH DELIMITER</code> and not <em>DELIMITERS</em>.</p> <p>Also, <code>COPY</code> syntax had changed and you're encouraged to use the following:</p> <pre><code>COPY location FROM 'file.csv' WITH (FORMAT csv, DELIMITER '\t', NULL 'NULL'); </code></pre> <hr> <p><strong>EDIT:</strong></p> <p>I've used the supplied information to test how <code>COPY</code> will work on the presented data: </p> <pre><code>CREATE TABLE atest ( countrycode text CHECK (length(countrycode) &lt;= 2), postalcode text CHECK (length(postalcode) &lt;=20), place text CHECK (length(place) &lt;= 100), state text CHECK (length(state) &lt;= 20), country text CHECK (length(country) &lt;= 100), country2 text CHECK (length(country2) &lt;= 20), community text CHECK (length(community) &lt;= 100), community2 text CHECK (length(community2) &lt;= 20), latitude double precision, longitude double precision, accuracy integer); </code></pre> <p>I've used the above mentioned command (adopted a bit):</p> <pre><code>COPY atest FROM '/Users/viy/atest2.csv' WITH (FORMAT csv, DELIMITER E'\t', NULL '\n'); </code></pre> <p>And got the same error as described above. This is expected, 'cos there're too many empty fields. Let's look at the <code>CSV</code> data and how it matches table definition (all <code>\t</code> replaced with new lines):</p> <pre><code>AD countrycode AD100 postalcode Canillo place \n state \n country \n country2 \n community \n community2 \n latitude 42.5833 longitude 1.6667 accuracy 6 &lt;-- this one gives the error! </code></pre> <p>So, in order to get data loaded you have to review your source data and remove an extra empty field in the middle. Another way is to adjust table's definition to match you source data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload