0

I am attempting to copy a csv file in a Cassandra table using

so in cqlsh, something like:

COPY mytable FROM 'test.csv' WITH header=TRUE;

problem is that in practice, my CSV file has more than a hundred columns. Is it necessary to define each column using

CREATE TABLE mytable (<all my columns here>);

or hopefully, is there some way to create the table f rom the column headers? I mean, I could write a short python script that reads the column headers and then outputs them into a format i can just copy and paste into , but I'm wondering if there's a more elegant way?

Thanks Alex

Mikhail Stepura
  • 3,374
  • 20
  • 16
alexizydorczyk
  • 850
  • 1
  • 6
  • 25

1 Answers1

1

No, there is no way to create a table from CSV in CQLSH. Unfortunately CSV doesn't contain information about columns' types, so CQLSH can't figure that out to create a table.

Mikhail Stepura
  • 3,374
  • 20
  • 16
  • Ah, good to know, thanks. Could you suggest any practical way of going about getting around this? Assuming, for instance, I can consider every column type text – alexizydorczyk Feb 21 '14 at 19:58
  • A perl/python script could easily create a CQL DDL definition for you. At least a stub, which you can adjust manually. – Mikhail Stepura Feb 21 '14 at 22:17