Cassandra Failed to import from CSV

Viewed 799

I'm running cassandra as a docker container and trying to import a CSV file into my table. I keep getting this error: Failed to import 0 rows: IOError - Can't open '/Users/myFilePath/Desktop/data.csv' for reading: no matching file found, given up after 1 attempts

I do have data.csv file on my desktop.

This is what my table looks like:

create table mydata
(
Rank int primary key,
Title varchar,
Genre SET<text>,
Director varchar,
Actors SET<text>,
Year int,
Runtime_Minutes int,
Rating varchar,
Votes int,
Revenue_Millions varchar,
Metascore int
);

This is how I'm trying to import the file: COPY mydata (Rank, Title, Genre, Director, Actors, Year, Runtime_Minutes, Rating, Votes, Revenue_Millions, Metascore) FROM '/Users/myFilePath/Desktop/data.csv' WITH HEADER = 'true';

Please kindly let me know what I'm doing wrong. Thank you so much and truly appreciate your help and time.

1 Answers

The most probable reason is that Cassandra/cqlsh doesn't have access rights for files on your desktop - such access is disabled by default on the latest versions of MacOS. Check Privacy settings in the Application settings.

I also recommend instead of using COPY ... FROM, use the DSBulk tool - it's heavily optimized for data loading/unloading for both CSV & JSON formats, and is very flexible.

DataStax blog has a series of articles about DSBulk: 1, 2, 3, 4, 5, 6

Related