【问题标题】:How to Select table from csv file in clickhouse with its column name as header如何从 clickhouse 中的 csv 文件中选择表并将其列名作为标题
【发布时间】:2022-12-22 06:42:46
【问题描述】:

我尝试使用 clickhouse 选择一个 csv 文件,但我的列标题名称不包括在内,而是变成了第 1 行,就像这张图片enter image description here

this is my code :
SELECT 
    *
    FROM file(
        'trx_okt_2022.csv'
    )

what can i add so it can read its header column name

【问题讨论】:

  • 我尝试添加 CSV 格式 .. 结果为:代码:27。DB::ParsingException:无法解析输入:预期的 ',' 之前:\argo,C,,11,1,1,12359053\r\n2022-10- 01,1,988,PT Garuda':第 1 行:第 0 列,名称:日期,类型:日期,已解析文本:“date,Cli” 错误:日期后的垃圾:“entId,Pref” 错误:日期必须为 YYYY-MM -DD格式。 :执行 CSVRowInputFormat 时:执行文件时:(在文件/uri /var/lib/clickhouse/user_files/trx_okt_2022.csv 中):(在第 1 行)。 (CANNOT_PARSE_INPUT_ASSERTION_FAILED)

标签: csv clickhouse


【解决方案1】:

CSVWithNames 包括第一行作为列的标题。

从中读取的方法是:

SELECT * FROM file('trx_okt_2022.csv', 'CSVWithNames');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-09
    • 2013-08-21
    • 2020-07-27
    • 2019-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多