导入数据时遇到错误字符 (ASCII 0) [英] Bad character (ASCII 0) encountered while importing data

查看:36
本文介绍了导入数据时遇到错误字符 (ASCII 0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入一些数据并收到错误遇到错误字符(ASCII 0)"

I am trying to import some data and getting the error "Bad character (ASCII 0) encountered"

我要导入的文件位于http://commondatastorage.googleapis.com/snksales/dimdistributor.csv

无法理解如何解决这个问题.

not able to understand how to fix this.

谢谢,

推荐答案

此文件似乎已编码为 UTF-16.BigQuery 仅支持 UTF-8 和 latin1 文本编码.您可以将其重新格式化为 UTF-8 或 ascii 吗?如果您使用的是 Windows,您应该能够通过在记事本中执行另存为来设置编码.如果您使用的是 linux 或 mac,您应该可以这样做:iconv -f utf-16 -t utf-8 dimdistributor.csv -o dimdistributor_utf8.csv.我运行了后者并且能够导入您的数据.

This file appears to be encoded as UTF-16. BigQuery only supports UTF-8 and latin1 text encodings. Can you reformat it as UTF-8 or ascii? If you are using windows, you should be able to set the encoding by doing a save-as in notepad. If you are using linux or mac, you should be able to do: iconv -f utf-16 -t utf-8 dimdistributor.csv -o dimdistributor_utf8.csv. I ran the latter and was able to import your data.

$xxd dimdistributor.csv |头0000000: fffe 3100 2c00 3000 3000 3000 3000 3100 ..1.,.0.0.0.0.1.0000010: 3000 3000 3000 3000 3200 2c00 4d00 2e00 0.0.0.0.2.,.M...0000020: 4d00 2e00 4500 4e00 5400 4500 5200 5000 M...E.N.T.E.R.P.0000030: 5200 4900 5300 4500 5300 2c00 3200 0d00 R.I.S.E.S.,.2...0000040: 0a00 3200 2c00 3000 3000 3000 3000 3100 ..2.,.0.0.0.0.1.

$xxd dimdistributor.csv | head 0000000: fffe 3100 2c00 3000 3000 3000 3000 3100 ..1.,.0.0.0.0.1. 0000010: 3000 3000 3000 3000 3200 2c00 4d00 2e00 0.0.0.0.2.,.M... 0000020: 4d00 2e00 4500 4e00 5400 4500 5200 5000 M...E.N.T.E.R.P. 0000030: 5200 4900 5300 4500 5300 2c00 3200 0d00 R.I.S.E.S.,.2... 0000040: 0a00 3200 2c00 3000 3000 3000 3000 3100 ..2.,.0.0.0.0.1.

这篇关于导入数据时遇到错误字符 (ASCII 0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆