2016-10-25 139 views
0

基础知识:问题:Google Adwords的.cvs报告如何编码?编码/导入Adwords .CSV到powerquery

详细信息:我试图使用powerquery从我的生活中导入一个.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. UTC-16LE在M为代码页1200
  3. 我无法打开的Adwords .csv在任何编码设置(Unicode,Unicode Big Endian,UTF-8,ASNI)下的记事本
  4. 如果重新保存文件excel作为UnicodeText我可以用记事本打开它作为Unicode Big Endian,但没有逗号(“,”)。

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

回答

0

为什么使用行代替原生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