Error with cbimport csv file and key

Hello,

I m trying to import csv file to couchbase and I got à problem with key.

AJ_REJID;AJ_ADHID;AJ_DTENV;AJ_DTREJ;AJ_ECHAA;AJ_ECHMM;AJ_MTIMP;AJ_REJCOD
9615;10058;;2017-12-26;2017;12;12.00;20
9614;10264;;2017-12-26;2017;12;13.00;20
9613;18344;;2017-12-26;2017;12;189.00;20
9612;43312;;2017-12-26;2017;12;13.00;20
9617;20322;;2017-12-27;2017;12;12.00;20

I ve tried these syntaxes

cbimport csv -cluster http://127.0.0.1:8091 -bucket courtage -u Administrator -p xxx -d file://COURTAGE/AltCRej_2017_12_31_17H00.csv -g key
::%AJ_ADHD%::#MONO_INCR# -t 4

cbimport csv -cluster http://127.0.0.1:8091 -bucket courtage -u Administrator -p xxx -d file://COURTAGE/AltCRej_2017_12_31_17H00.csv -g key
::%AJ_ADHD%::#UUID# -t 4

and the same with -g key ::%AJ_ADHD%

And I always got this error

2018-02-12T15:31:05.706+01:00 ←[31mWARN: Unable to generate key for document{"AJ_REJID;AJ_ADHID;AJ_DTENV;AJ_DTREJ;AJ_ECHAA;AJ_ECHMM;AJ_MTIMP;AJ_REJCOD":"9615;10058;;2017-12-26;2017;12;12.00;20"}←[0m←[2m -- csvdata.(*csvSource).Data.func1() at source.go:176←[0m

Do I miss something ?

Thank

Clémence

You say -g key ::%AJ_ADHD%, but the column in your data named AJ_ADHID (missing I)

Got the same error

C:\Program Files\Couchbase\Server\bin>cbimport csv -cluster http://127.0.0.1:8091 -bucket courtage -u Administrator -p xxx -d file://COURTAGE/AltCRej_2017_12_31_17H00.csv -g key
::%AJ_ADHID% -t 4
2018-02-12T16:53:56.386+01:00 ←[31mWARN: Unable to generate key for document{"AJ_REJID;AJ_ADHID;AJ_DTENV;AJ_DTREJ;AJ_ECHAA;AJ_ECHMM;AJ_MTIMP;AJ_REJCOD":"9614;10264;;2017-12-26;2017
;12;13.00;20"}←[0m←[2m -- csvdata.(*csvSource).Data.func1() at source.go:176←[0m

I have also tried with other column without more success

I m testing with simple file

NOM;PRENOM
A;b
R;h

I got same error again

C:\Program Files\Couchbase\Server\bin>cbimport csv -cluster http://127.0.0.1:8091 -bucket courtage -u Administrator -p xxx-d file://COURTAGE/test.csv -g key::%PRENOM% -t 4
2018-02-13T09:18:27.692+01:00 ←[31mWARN: Unable to generate key for document{“NOM;PRENOM”:“A;b”}←[0m←[2m – csvdata.(*csvSource).Data.func1() at source.go:176←[0m
2018-02-13T09:18:27.711+01:00 ←[31mWARN: Unable to generate key for document{“NOM;PRENOM”:“R;h”}←[0m←[2m – csvdata.(*csvSource).Data.func1() at source.go:176←[0m
2018-02-13T09:18:27.717+01:00 ←[31mERRO: Some errors occurred while transfering data, see logs for more details←[0m←[2m – plan.(*data).execute() at data.go:89←[0m
CSV import failed: Some errors occurred while transfering data, see logs for more details

C:\Program Files\Couchbase\Server\bin>cbimport csv -cluster http://127.0.0.1:8091 -bucket courtage -u Administrator -p xxx -d file://COURTAGE/test.csv -g key::%NOM% -t 4
2018-02-13T09:14:26.380+01:00 ←[31mWARN: Unable to generate key for document{“NOM;PRENOM”:“R;h”}←[0m←[2m – csvdata.(*csvSource).Data.func1() at source.go:176←[0m
2018-02-13T09:14:26.398+01:00 ←[31mWARN: Unable to generate key for document{“NOM;PRENOM”:“A;b”}←[0m←[2m – csvdata.(*csvSource).Data.func1() at source.go:176←[0m
2018-02-13T09:14:26.404+01:00 ←[31mERRO: Some errors occurred while transfering data, see logs for more details←[0m←[2m – plan.(*data).execute() at data.go:89←[0m
CSV import failed: Some errors occurred while transfering data, see logs for more details

I think the issue is that you are doing a csv (comma seperated value) import, but your data is separated by semicolons, not commas. I tried your data with commas, and it worked fine.

I got a way by removing % %

cbimport csv -cluster http://127.0.0.1:8091 -bucket courtage -u Administrator -p xxx -d file://COURTAGE/AltCCtr_2017_12_31_17H00 -g key::AA_ADHID::#MONO_INCR#

Also windows cmd.exe is using % signs for variable interpolation.

1 Like

@avsej,

I was using Powershell. I assumed (perhaps wrongly) that everyone is using powershell instead of cmd.exe these days.

how do we import documents -g with meta().id ? is this require any special cbexport options ,please suggest them as well.

This would be better asked as a new question rather than reviving a topic from 2018.

Explore the --include-key option of cbexport to include the key in the exported data and the use the %field% syntax in cbimport’s -g option for importing using the exported key values.