How To Import Data From Excel Or CSV Files To Cassandra Database

How To Import Data From Excel Or CSV Files To Cassandra Database

access_timeWednesday, 25 April, 2018 chat_bubble_outline0 comments

Cassandra is a NoSQL database, so it didn't have any fixed schema or structure. 

There are many different ways to import/ insert data on Cassandra Database like...

1) Through the simple CQL insert command.

2) Through the copy command.

3) Through the SStabeloader.

 

In this article, we will learn how to Upload/Import/Insert data on Cassandra Database through "Copy" command.

We have to use "Copy" command when we import data from a CSV or Excel file and also the size of data is not too large or the number of rows in few thousands only.

 The "Copy" command to upload the data in Cassandra Database is:-

COPY product.product_category (col1,col2,col3.....) FROM 'C:\Users\Public\Downloads\product_category.csv' WITH DELIMITER='|' AND HEADER=TRUE;

For better understanding, I will describe all the keyword/attributes of the above-mentioned command.

COPY:- it's the static keyword.

product:- it is the keyspace name where your table exists.

product_category:- it is the table name where we want to insert data.

FROM:- it's also the static keyword.

'C:\Users\Public\Downloads\product_category.csv':- this is the path of the excel or CSV file which you are trying to import.  

WITH:-  it's also the static keyword.

DELIMITER:- it's a separator of your CSV file.

HEADER:- it's value is true or false, if the file contains the header row then it's value is true else the value is false.

hopefully this article will help you to import data on Cassandra Database from Excel or CSV files.

 

If anyone has any queries or any suggestions or any new ways to import/upload data on Cassandra Database from any type of file please let us know in the comment box. 

folder_openAssigned tags

0 Comments

Leave a Comment: