Tim*_*Tim 2 csv excel powerpivot powerquery
我正在尝试自动化一些基于 Netsuite(我们的 ERP 软件)导出的 CSV 构建的报告。这些文件永远不会正确地直接导入到 PowerQuery 中,因为有 6 行是“标题”行。这些标题行没有正确数量的逗号,因此 PowerQuery 仅显示 1 列数据。我目前正在使用 Notepad++ 打开文件并删除这 6 行,然后将文件导入 PowerQuery。
有没有办法使用 PowerQuery 代码跳过前 6 行,以便正确读取 csv?以下是我正在使用的数据的示例。
Fake Cocoa Company LLC
"Fake Cocoa Company, LLC (Consolidated)"
Sales Order Detail - Hotel - BH
"January 1, 2016 - December 31, 2016"
"Options: Show ZerosFilters: Customer/Project (equal to FCC - Hotel Hotel ), Validated Status (not equal to Cancelled, Closed )"
Document Number ,Date ,Ship To ,Item: Description (Sales) ,Quantity ,Validated Status ,Unit Price ,Aggregate Amount
Sales Orders,,,,,,,
669,9/15/2016,Receiving - CCLV Hotel 2880 Some Place Blvd South Hotel Hotel Some Place CA 91089,100% Country Caf Liquid Cocoa,5,Billed,$75.68,$378.40
660,,,,,,,
,9/15/2016,Receiving - MAIN OCEAN Hotel 4300 Some Place Blvd SO Some Place CA 91089,100% Country Caf Liquid Cocoa,10,Billed,$7.68,$75.80
,9/15/2016,Receiving - MAIN OCEAN Hotel 4300 Some Place Blvd SO Some Place CA 91089,Fake Cocoa Grand - Whole Bean 5/5LB,8,Billed,$17.80,$72.00
,9/15/2016,Receiving - MAIN OCEAN Hotel 4300 Some Place Blvd SO Some Place CA 91089,Fake Cocoa Grand 28/9oz,6,Billed,$5.54,$39.24
,9/15/2016,Receiving - MAIN OCEAN Hotel 4300 Some Place Blvd SO Some Place CA 91089,Fake Cocoa Grand 42/2oz,4,Billed,$1.32,$7.28
,9/15/2016,Receiving - MAIN OCEAN Hotel 4300 Some Place Blvd SO Some Place CA 91089,Fake Cocoa Caf - Whole Bean 5/5LB,2,Billed,$2.80,$28.00
Total - 660,,,,,,,"$203.32"
Run Code Online (Sandbox Code Playgroud)
let
file_path = "C:\your_path\csv.txt",
file = File.Contents(file_path),
src = Lines.FromBinary(file),
skip = List.Skip(src,6),
combine = Text.Combine(skip, "#(lf)"),
csv = Csv.Document(combine),
promote = Table.PromoteHeaders(csv)
in
promote
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8350 次 |
| 最近记录: |