【问题标题】:Csv not getting loaded int BIgquery issue with "\ double quotes and delimeter repeated twiceCsv 未加载到 BIgquery 问题,“\ 双引号和分隔符重复两次
【发布时间】:2021-10-18 13:38:48
【问题描述】:

将下方行加载到 BQ 中的问题。我已经尝试过有关 stackoverflow 的建议,但没有运气。以下是我的数据:

Id;描述;curator_id;Q_code;ITG_NUM ABC;“天气适合滑雪\”B\””;ROLLON;HFCKQ:5051 CDE;"难怪好"B"";;MOVEON;CKHLP;5058

我按照建议添加了以下参数:

job_config = bigquery.LoadJobConfig(
        autodetect=True,
        source_format=bigquery.SourceFormat.CSV,
        quote_character = '"',
        encoding='UTF-8',
        field_delimiter=';',
        write_disposition="WRITE_APPEND",
        skip_leading_rows=1,
    )

但仍然出现错误: 解析从以下位置开始的行时检测到错误:155482。 错误:右双引号 (") 和字段分隔符之间的数据。

有什么建议吗?

【问题讨论】:

标签: python csv google-bigquery google-cloud-functions


【解决方案1】:

如果您在关闭自动换行的情况下在 Notepad++ 中打开数据文件,请按 Ctrl G,然后选择“偏移”单选按钮,然后您可以输入您的位置 #155482 进行搜索。这会将您带到错误所在/检测到的位置。最有可能的是,它是数据字段中嵌入的双引号(在逗号分隔符之间)。

【讨论】:

  • 所以我尝试使用以下命令替换,但它不是。任何建议:对于 read_file 中的行:striped_line = line.strip() new_line = stripped_line.replace('\"', '" ') reading_file.close() new_file_content += new_line+"\n" writing_file = open("file", "w") writing_file.write(new_file_content) writing_file.close()
猜你喜欢
  • 2014-10-03
  • 1970-01-01
  • 2017-09-28
  • 2012-09-03
  • 1970-01-01
  • 1970-01-01
  • 2015-01-06
  • 1970-01-01
  • 2017-02-19
相关资源
最近更新 更多