【问题标题】:Automatic import Google Play Console reports from Google Cloud Storage into BigQuery自动将 Google Play Console 报告从 Google Cloud Storage 导入 BigQuery
【发布时间】:2018-03-20 11:11:01
【问题描述】:

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.

【问题讨论】:

  • (Get-Content -Path $Path) | Out-File -FilePath $Path -Encoding UTF8

标签: powershell cmd google-bigquery google-cloud-storage google-play-console


【解决方案1】:

正如TheIncorrigible1所说,可以使用Powershell进行编码转换

(Get-Content -Path $Path) | Out-File -FilePath $Path -Encoding UTF8 

此命令会将 CSV 文件从 UTF-16 转换为 UTF-8 in。您可能必须在第一个命令中指定编码为这样

(Get-Content -Path $Path -Encoding UTF16) | Out-File -FilePath $Path -Encoding UTF8`

ajkthis post中有详细解答

【讨论】:

    猜你喜欢
    • 2023-04-08
    • 2021-07-27
    • 2017-11-13
    • 2018-06-20
    • 2017-11-25
    • 1970-01-01
    • 2016-07-18
    • 1970-01-01
    • 2019-05-29
    相关资源
    最近更新 更多