How to upload .tsv files to cassandra

I am trying to upload a CSV file to Cassandra using "|" as a delimiter, but one of the records has this, and there is a record mismatch error. I tried other delimiters, but they are present in the entries. When I use tabs or special characters as separators, I get this error:

"delimiter" must be a 1 character string

Is there a way to upload .tsv files directly to Cassandra?

+6
source share
1 answer

What version of Cassandra are you using?

There is a ticket in the Cassandra JIRA project ( CASSANDRA-6773 ). According to the ticket, it seems that the fix has been completed and applied since 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.

+2
source

Source: https://habr.com/ru/post/973267/


All Articles