5

I've spent the past two days checking the available answers on this site and a few other sites. I need help with the following (COPY FROM a CSV file) issue I'm encountering. I created the KEYSPACE and COLUMN FAMILY without any issues, but I receive a COLUMN FAMILY NOT FOUND when I attempt to copy a CSV file into the Table/Column Family. I've included the syntax I'm using below. I would truly appreciate help with resolving this matter. (Cassandra 2.0.6, CQL3.1.1)

I'm new to CQLSH.

CREATE KEYSPACE KS_TERA
  WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };

CREATE COLUMNFAMILY TERA
         (BIT_ID int PRIMARY KEY,
    YEAR int ,  
    DAY_OF_MONTH int ,
    BIT_DATE timestamp ,
    COMP_ID int ,
    CARRIER varchar ,
    CARRIER_NUM int ,
    ORIGIN_SHIP_ID int 
         )
          WITH COMPACT STORAGE;

COPY TERA FROM ‘TERA.CSV’  WITH DELIMITER = ‘,’ AND HEADER = FALSE;

I get a COLUMN FAMILY NOT FOUND error.

bjb568
  • 11,089
  • 11
  • 50
  • 71
Cary
  • 51
  • 1
  • 4

2 Answers2

2

That's because COPY command is case sensitive, you must replace the name of table (column family) and its columns in your command like this:

COPY tera FROM ‘TERA.CSV’  WITH DELIMITER = ‘,’ AND HEADER = FALSE;

if you have columns, then like this:

COPY tera (column1, column2, ... , columnn) FROM ‘TERA.CSV’  WITH DELIMITER = ‘,’ AND HEADER = FALSE;

Hope it helps to someone now...

jcflorezr
  • 326
  • 4
  • 13
1

Are you using the below query for copying into column-family? if not then try it will work as per your expectation.

COPY keyspace.columnfamily1 (column1, column2,...) TO 'temp.csv';
COPY keyspace.columnfamily2 (column1, column2,...) FROM 'temp.csv';
Helping Hand..
  • 2,430
  • 4
  • 32
  • 52