I have got C-ISAM data exported to ASCII file and now I would like to import that into Cassandra database. Is there any way to do so? For information the ASCII file is based on offsets!
Thanks for the help!
You'll need to use COPY FROM
, but you'll need some preprocessing. COPY is not a CQL statement, but rather a CQLSH command, so you can only run this from the CQL Shell.
First, you'll need to create the table you want to import into. This is where you define all the columns.
Secondly, here is the command syntax for import (delimiter is optional and more options are supported: see here):
COPY mytable([col1, col2, etc...]) FROM ('file.txt') WITH DELIMITER=',';
Lastly, and here comes a little bit of extra work, Cassandra can only import CSV data (where columns are delimited by separators) as opposed to offset-based. To solve this issue, I would write a small script in your favorite language that would read your existing ASCII file and convert it to CSV format line by line. This should take not more than 2 dozen of lines of code, so it should be a no-brainer.
EDIT: as zubs observed in the comments below, some third-party applications such as Excel can be leveraged to convert to CSV format removing the need to write custom code.