COPY command in Cassandra breaks in to adjacent cell the sentence in csv file

Viewed 193

I am using copy command in cassandra:

COPY table_name TO 'path/file.csv' with HEADER = TRUE;

After copying in csv, one of the cell value (which is very long string) is broken in pieces and scattered in adjacent cell overlapping under another column.

Need solution to imply this properly.

2 Answers

one of the cell value (which is very long string) is broken in pieces and scattered in adjacent cell overlapping under another column.

It sounds like that cell value may contain commas, causing it to be split prematurely. Try using a different delimiter. For example, if your text data doesn't contain pipes, then this should work:

COPY table_name TO 'path/file.csv' with DELIMITER='|' AND HEADER = TRUE;

Instead of using the COPY command that has quite limited capabilities and also problematic to use for big amounts of data, I suggest to use DSBulk tool to export or import data to/from CSV and JSON formats - it is heavily optimized for fast data export/import, and is very configurable. It could be as simple as (CSV is default format):

dsbulk unload -k keyspace -t table -url filename

You can control what columns to export, store data in compressed files, etc. See following blog posts for examples:

Related