使用cassandra cql加载雅虎金融csv格式数据时遇到错误

Meet an error when I use cassandra cql to load Yahoo financial csv formated data

我想使用 Cassandra cql 导入 Yahoo financial csv 格式的数据。部分数据文件:

    Date           Open        High         Low        Close    Volume  Adj Close
   1/15/2016    130.009995  130.880005  128.869995  130.029999  8895400 130.029999
   1/14/2016    131.929993  133.789993  131.220001  132.910004  5703100 132.910004
   1/13/2016    133.5   134.279999  131.100006  131.169998  4672300 131.169998
   1/12/2016    133.649994  133.779999  131.130005  132.899994  5073700 132.899994
   1/11/2016    131.809998  133.820007  131.759995  133.229996  4967000 133.229996

这是我定义的架构:

    create table HisPrice (
    Date text primary key,
    Open float,
    High float,
    Low float,
    Close float,
    Volume int, 
    AdjClose float
    );

当我使用此架构并使用复制命令时 COPY HisPrice (Date, Open, High, Low, Close, Volume, AdjClose) from '\filename.csv ',我得到以下错误:

在输入 ',' (..., adjclose) 值 ('Date',[Open],...) 处没有可行的替代方案

如果我将所有数据类型定义为文本,例如(低文本),则不会出现错误。

根据错误消息判断,我认为您可以尝试删除 CSV 的 header。

使用 Cassandra 3.2,还有一个选项可以跳过前 N 行:SKIPROWS。

读这个:http://www.datastax.com/dev/blog/new-features-in-cqlsh-copy