Reputation: 593
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?
Upvotes: 6
Views: 2738
Reputation: 57748
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.
Upvotes: 3