kumarhimanshu449
kumarhimanshu449

Reputation: 830

Cassandra COPY FROM file pattern gives error

My cassandra version: 2.0.17. I am following this https://www.datastax.com/dev/blog/new-features-in-cqlsh-copy post to copy all of my csv files placed in a folder to a Cassandra table. But it shows me error saying No such file or directory.

When I try to copy individual files using below command it works very well:

COPY table FROM '/home/folder1/a.csv' WITH DELIMITER=',' AND HEADER=FALSE;

There are multiple csv files in /home/folder1 location. So I tried to copy all the csv files in a single go using below command:

COPY table FROM '/home/folder1/*.csv' WITH DELIMITER=',' AND HEADER=FALSE;

When I run the above command it gives me below error:

Can't open '/home/folder1/*.csv' for reading: [Errno 2] No such file or directory: '/home/folder1/*.csv'

Please help to solve this issue.

Upvotes: 0

Views: 1107

Answers (1)

Alex Ott
Alex Ott

Reputation: 87164

The blog post says

We will review these new features in this post; they will be available in the following cassandra releases: 2.1.13, 2.2.5, 3.0.3 and 3.2.

So the 2.0.17 doesn't have this functionality. If you want to load all .csv files from directory, just use:

for i in /home/folder1/*.csv ; do 
    echo "COPY table FROM '$i' WITH DELIMITER=',' AND HEADER=FALSE;"|cqlsh -f -
done

Upvotes: 1

Related Questions