how to use ascii character for quote in COPY in cqlsh

cassandra cql3 cqlsh csv sqlbulkcopy

Question

I'm using copy in cqlsh to transfer data from a large.csv file into Cassandra. I'm using CQL 3.0 and Cassandra 1.2. I must use another character to submit my data since " is a part of it; I must use any extended ASCII letters. I attempted a number of things but failed.

The following is functional, however for my needs I must use extended ASCII characters.

copy (<columnnames>) from <filename> where deleimiter='|' and quote = '"';
copy (<columnnames>) from <filename> where deleimiter='|' and quote = '~';

When I enter quote=", I get the following error:

:"quotechar" must be an 1-character string

Please provide me guidance on how to set the quotation parameter to utilize an expanded ASCII character.

I appreciate you.

1
0
7/18/2013 8:56:49 PM

Popular Answer

I looked at the cqlsh script's source code since I was experiencing a similar issue. Finding the appropriate python csv settings was necessary in my situation since I was using Python to generate the csv.

Here is the important data from cqlsh:

    csv_dialect_defaults = dict(delimiter=',', doublequote=False,
                            escapechar='\\', quotechar='"')

It thus just requires using the csv module with: assuming you are fortunate enough to produce your.csv file using Python.

    writer = csv.writer(open("output.csv", 'w'), **csv_dialect_defaults)

Even if you are not using Python, I hope this helps.

0
9/12/2014 11:43:04 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow