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

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

问题描述

我试图导入一些数据并得到错误遇到错误的字符(ASCII 0)

我试图导入的文件是
http://commondatastorage.googleapis.com/snksales/dimdistributor.csv



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

thx,

解决方案

该文件似乎被编码为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 。我运行后者,并能够导入您的数据。



$ 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 RISES,.2 ...
0000040:0a00 3200 2c00 3000 3000 3000 3000 3100 ..2。,。0.0.0.0.1。


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

the file i'm trying to import is at http://commondatastorage.googleapis.com/snksales/dimdistributor.csv

not able to understand how to fix this.

thx,

解决方案

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 | 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天全站免登陆