s offering, and it
非常丑陋的官方数据。没有UTF8,我看到http://data.gov.ro/storage/f/2013-11-01T13:59:27.012Z/contracte-2007.csv CREATE TABLE
代码
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
);
SQL代码
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';
我得到的错误:
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"
如果我尝试添加CSV标题,那么我会收到另一个错误
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 **********
答案 0 :(得分:0)
这不是对错命令的问题,问题似乎是数据质量
当我跑
时\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 'contracte-2007.csv'
( format csv, header, delimiter '^', encoding 'win1252', null '/N' );
我得到了
ERROR: missing data for column "subcontractat"
CONTEXT: COPY contracte, line 8659: "INSTITUTUL NATIONAL CERCETARE DEZVOLTARE PTR.PROTECTIA MUNCII-INCDPM,,ALEXANDRU DARABONT"^1558391^Ro..."
如您所见,它是第8659行。