Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra CQL3 Import CSV

Tags:

cassandra

Background:

I have created a Schema called AvailableDomains (simple strategy, 1 node).

In that keyspace I have created 1 table/ column family called domains with columns (id, urn, timestamp, flag). All of type text except timestamp is type timestamp.

I startup cassandra,

launch cqlsh -3,

use AvailableDomains,

and then issue the following command to pull in a csv:

COPY domains (id, urn, timestamp, flag) from 'test.csv' where HEADER= TRUE;

I get an error saying: Improper COPY command

Question: What am I doing wrong?

Details:

CSV-

id,url,timestamp,flag
1,google.com,1375891081,1
2,facebook.com,1375891081,1
3,youtube.com,1375891081,1
4,yahoo.com,1375891081,1
5,baidu.com,1375891081,1
6,wikipedia.org,1375891081,1
7,amazon.com,1375891081,1
8,qq.com,1375891081,1
9,live.com,1375891081,1
10,linkedin.com,1375891081,1

Location of csv is in cassandra/bin (same dir where cqlsh is located).

OS: Centos 6.4 64bit

like image 995
Chris Avatar asked Aug 07 '13 17:08

Chris


1 Answers

This fixed me up for CQL 3:

COPY domains FROM 'test.csv' WITH HEADER = true ;

The reason I am using Header = True is the first line of my CSV has the column names. Hope this helps someone else out there.

like image 59
Chris Avatar answered Sep 28 '22 07:09

Chris