Google Play控制台报告使用的是UTF-16编码,BigQuery - UTF-8。
如何自动将CSV文件从UTF-16转换为UTF-8?
我在PowerShell中的代码:
$date = (Get-Date).AddDays(-2).Date.ToString('yyyy-MM')
$date2 = $date.Replace('-', '')
$typefile = 'app_version'
$table = $typefile + '$' + $date2 + '01'
$csv_file = 'gs://pubsite_prod_rev_******_'+ $date2 + '_' + $typefile + '.csv'
$csv_file2 = $date2 + '_' + $typefile + '.csv'
& gsutil cp $csv_file C:\***\Scripts\gc\$csv_file2
& bq load --replace report.$table C:\***\Scripts\gc\$csv_file2
错误:
BigQuery error in load operation: Error processing job
'majestic-cairn-****:bqjob_r171ebea2_*****_1': Error while reading
data, error message: CSV table encountered too many errors, giving up. Rows: 1;
errors: 1. Please look into the error stream for more details.
Failure details:
- file-00000000: Error while reading data, error message: Too many
values in row starting at position: 0.
答案 0 :(得分:0)
如上所述TheIncorrigible1
,可以使用Powershell进行编码转换
(Get-Content -Path $Path) | Out-File -FilePath $Path -Encoding UTF8
此命令会将CSV文件从UTF-16
转换为UTF-8
。您可能必须在第一个命令中指定编码,因此
(Get-Content -Path $Path -Encoding UTF16) | Out-File -FilePath $Path -Encoding UTF8`
中的ajk
有详细解答