2

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

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

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

谢谢,

4

2 回答 2

8

该文件似乎被编码为 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 3200 2C00 4D00 2E00 0.0.0.0.2。,。0000020:4D00 5000 M ... Enterp 0000030 2 ... 0000040:0a00 3200 2c00 3000 3000 3000 3000 3100 ..2.,.0.0.0.0.1。

于 2012-07-24T18:21:38.297 回答
0

尝试使用以下 PowerShell 脚本清理文件:

   $configFiles = Get-ChildItem -Path C:\InputPath\* 
   foreach ($file in $configFiles)
   {
         (Get-Content $file.PSPath) |
         Foreach-Object { $_ -replace "`0", "" } |
         Set-Content $file.PSPath
   }

要使用它,只需将文件复制到 C:\InputPath 中,将脚本另存为 Script.ps1 并使用 PowerShell 运行它

于 2020-12-10T20:22:43.777 回答