title: Importing CSV to postgres with new columns
body: <p>I have an issue importing csv data to a postgres database with geo data / postgis enabled via the following command on my database 'landmarks':</p>
  
  <pre><code>CREATE EXTENSION postgis;
  </code></pre>
  
  <p>So.... the story goes:</p>
  
  <p>I am following this <a href="http://www.kevfoo.com/2012/01/Importing-CSV-to-PostGIS/" rel="nofollow noreferrer">tutorial</a>.</p>
  
  <p>I am trying to import a csv with these columns</p>
  
  <pre><code>name    conf    capital venture latitude    longitude
  </code></pre>
  
  <p>the first line, as an example of the data, is:</p>
  
  <pre><code>example, 1, 1, 1, 51.51923, -0.12205
  </code></pre>
  
  <p>I have set the table up following the tutorial except adding conf, capital and venture instead of the columns in his data (address, date_built, architect, landmark). i.e.:</p>
  
  <pre><code>CREATE TABLE landmarks
  (
    gid serial NOT NULL,
    name character varying(50),
    conf character varying(10),
    capital character varying(10),
    venture character varying(10),
    the_geom geometry,
    CONSTRAINT landmarks_pkey PRIMARY KEY (gid),
    CONSTRAINT enforce_dims_the_geom CHECK (st_ndims(the_geom) = 2),
    CONSTRAINT enforce_geotype_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL),
    CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 4326)
  );
  </code></pre>
  
  <p>then</p>
  
  <pre><code>CREATE INDEX landmarks_the_geom_gist
    ON landmarks
    USING gist
  (the_geom );
  </code></pre>
  
  <p>The data is essentially the same otherwise to his <a href="http://cache.kevfoo.com/data/Individual_Landmarks.csv" rel="nofollow noreferrer">example</a>.</p>
  
  <p>I've set the table up properly and enabled the postgis extension to deal with geom data fine.</p>
  
  <p>However, the problem comes when I try to import my csv:</p>
  
  <pre><code>landmarks=# \copy landmarks(name,conf,capital,venture,latitude,longitude) FROM '../../../../../var/tmp/map2.csv' DELIMITERS ',' CSV HEADER;
  ERROR:  column "latitude" of relation "landmarks" does not exist
  </code></pre>
  
  <p>Now, I noticed that when he creates the table, he doesn't add latitude or longitude columns... so I wondered if that was the issue and tried to create another table with those columns as well as integers, however that just gives me this error:</p>
  
  <pre><code>ptmap3=# \copy landmarks(name,conf,capital,venture,latitude,longitude) FROM '../../../../../var/tmp/map2.csv' DELIMITERS ',' CSV HEADER;
  ERROR:  invalid input syntax for integer: "51.51923"
  CONTEXT:  COPY landmarks, line 2, column latitude: "51.51923"
  </code></pre>
  
  <p>So... it seems that if I add the latitude column then it works, but fails with the data? After checking the csv for errors using this</p>
  
  <pre><code>od -c map2.csv
  </code></pre>
  
  <p>...there is nothing wrong with my csv (no hidden characters or errors)... so what's the deal?</p>
  
  <p>If anyone can help me import my csv to this db I'd be very grateful!</p>