Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to load .tsv files into cassandra

I am trying to load .csv file into Cassandra with "|" as a delimiter but one of the record has got that & there is a record mismatch error. I have tried other delimiters but they are present in the records. When I use tab or special symbols as delimiters am getting this error:

"delimiter" must be an 1-character string"

Is there a way to load .tsv files directly into Cassandra?

like image 637
Pavan Chakravarthy Avatar asked Aug 02 '14 20:08

Pavan Chakravarthy


1 Answers

Which version of Cassandra are you using?

There is a ticket (CASSANDRA-6773) for this issue in the Cassandra JIRA project. According to the ticket, it looks like the fix has been committed and applied as of version 2.0.7.

I just tried it and it worked for me (version 2.0.9):

[cqlsh 4.1.1 | Cassandra 2.0.9 | CQL spec 3.1.1 | Thrift protocol 19.39.0]

cqlsh> use stackoverflow;
cqlsh:stackoverflow> COPY trainsbydeparturetime(identifier, train_number,
    origin_train_station, dest_train_station, departure_time, total_travel_time )
    FROM '~/trainTimes.tsv' WITH DELIMITER='\t';

2 rows imported in 0.116 seconds.

Note the use of WITH DELIMITER='\t' at the end.

like image 119
Aaron Avatar answered Oct 13 '22 11:10

Aaron