2016-10-25 140 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