PostgreSQL ERROR: missing data for column
<ul>
<li>UPDATE - this is the official data that the government it<code>s offering, and it</code>s really ugly. No UTF8, broken rows from what i see <a href="http://data.gov.ro/storage/f/2013-11-01T13:59:27.012Z/contracte-2007.csv" rel="nofollow">http://data.gov.ro/storage/f/2013-11-01T13:59:27.012Z/contracte-2007.csv</a></li>
</ul>

<p><code>CREATE TABLE</code> code</p>

<pre><code>CREATE TABLE contracte (
  castigator text,
  castigatorcui text,
  castigatortara text,
  castigatorlocalitate text,
  castigatoradresa text,
  tip text,
  tipcontract text,
  tipprocedura text,
  autoritatecontractanta text,
  autoritatecontractantacui text,
  tipac text,
  tipactivitateac text,
  numaranuntatribuire text,
  dataanuntatribuire text,
  tipincheierecontract text,
  tipcriteriiatribuire text,
  culicitatieelectronica text,
  numaroferteprimite text,
  subcontractat text,
  numarcontract text,
  datacontract text,
  titlucontract text,
  valoare text,
  moneda text,
  valoareron text,
  valoareeur text,
  cpvcodeid text,
  cpvcode text,
  numaranuntparticipare text,
  dataanuntparticipare text,
  valoareestimataparticipare text,
  monedavaloareestimataparticipare text,
  fonduricomunitare text,
  tipfinantare text,
  tiplegislatieid text,
  fondeuropean text,
  contractperiodic text,
  depozitegarantii text,
  modalitatifinantare text
);
</code></pre>

<p>SQL Code</p>

<pre><code>COPY contracte(Castigator,CastigatorCUI,CastigatorTara,CastigatorLocalitate,
   CastigatorAdresa,Tip,TipContract,TipProcedura,AutoritateContractanta,
   AutoritateContractantaCUI,TipAC,TipActivitateAC,NumarAnuntAtribuire,DataAnuntAtribuire,
   TipIncheiereContract,TipCriteriiAtribuire,CuLicitatieElectronica,NumarOfertePrimite,
   Subcontractat,NumarContract,DataContract,TitluContract,Valoare,Moneda,ValoareRON,
   ValoareEUR,CPVCodeID,CPVCode,NumarAnuntParticipare,DataAnuntParticipare,
   ValoareEstimataParticipare,MonedaValoareEstimataParticipare,FonduriComunitare,
   TipFinantare,TipLegislatieID,FondEuropean,ContractPeriodic,DepoziteGarantii,
   ModalitatiFinantare) 
FROM 'C:\\Sinaia\SEAP 2007-2015\contracte-2009.csv'
WITH DELIMITER '^'encoding 'WIN1252' NULL AS '/N';
</code></pre>

<p>Error that I get:</p>

<pre><code>ERROR:  missing data for column "tip"
    CONTEXT:  COPY contracte, line 5312: "SC EUROSTRADE 
    SRL^7695851^Romania^Jilava^sediul social- Comuna Comana, Judetul Giurgiu"
    ********** Error **********

ERROR: missing data for column "tip"
SQL state: 22P04
Context: COPY contracte, line 5312: "SC EUROSTRADE SRL^7695851^Romania^Jilava^sediul social- Comuna Comana, Judetul Giurgiu"
</code></pre>

<p>If i try to add the CSV header then i get another error</p>

<pre><code>ERROR:  extra data after last expected column
CONTEXT:  COPY contracte, line 5209: "S.C. ELECTRA LUC S.R.L.^12094467^Romania^Bucuresti^Bucuresti, str. Vasile Lascar nr. 165, sector 2^A..."
********** Error **********
</code></pre>