【问题标题】:Encoding/import Adwords .CSV into powerquery将 Adwords .CSV 编码/导入到 powerquery
【发布时间】:2016-10-25 01:05:27
【问题描述】:

基础知识:问题所在:来自 Google Adwords 的 .cvs 报告是如何编码的?

详细信息:我正在尝试使用 powerquery 从 adwords 导入 .csv,但在我的一生中,我无法让“,”(逗号)字符出现在我的导入中。

我的代码:

let
// Get raw file data as txt file,
fnRawFileContents = (fullpath) as table =>
let
    EveryLine = Lines.FromBinary(File.Contents(fullpath),1,true,1200),
    Value = Table.FromList((EveryLine),Splitter.SplitByNothing())
in
    Value,

// Use functions to load contents
   Source =  fnRawFileContents("C:\Users\Jamie.Marshall\Desktop\Emma\adwordsDoc.csv"),
    #"Removed Top Rows" = Table.Skip(Source,1)
in
    #"Removed Top Rows"

事实:

  1. Adwords 文档说他们使用 UTC-16LE
  2. M 中的 UTC-16LE 是代码页 1200
  3. 在任何编码设置(Unicode、Unicode Big Endian、UTF-8、ASNI)下,我都无法在记事本中打开 Adwords .csv
  4. 如果在 excel 中将文件重新保存为 UnicodeText,我可以使用记事本将其打开为带有换行符的 Unicode Big Endian,但没有逗号 (",")。

  • 如何验证这些文档的编码?
  • 这可能是什么其他编码?
  • 我们将不胜感激任何帮助。

【问题讨论】:

    标签: unicode encoding google-ads-api powerquery m


    【解决方案1】:

    为什么你使用行而不是原生 csv 解析器?

    使用Csv.Document(file_content, [Delimiter="#(tab)", Columns=10, Encoding=1200, QuoteStyle=QuoteStyle.None])

    这样

    let
        file_path = "C:\Users\Jamie.Marshall\Desktop\Emma\adwordsDoc.csv",
        file_content = File.Contents(file_path),
        csv = Csv.Document(file_content, [Delimiter="#(tab)", Columns=10, Encoding=1200, QuoteStyle=QuoteStyle.None]),
        skip_1_row = Table.Skip(csv,1),
        promote_header = Table.PromoteHeaders(skip_1_row),
        remove_last_2_rows = Table.RemoveLastN(promote_header,2)
    in
        remove_last_2_rows
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 1970-01-01
      • 2015-06-13
      • 1970-01-01
      相关资源
      最近更新 更多