简体   繁体   English

来自多个 csv 文件的数据未在 Excel 中合并

[英]Data from multiple csv file is not consolidating in Excel

I'm trying to consolidate data from multiple csv files in excel sheet using Data-.我正在尝试使用 Data- 合并来自 Excel 工作表中多个 csv 文件的数据。 New Query-.From File option.新的 Query-.From File 选项。

However after doing "Combine and Load" data is not flowing completely in Excel.但是,在执行“组合和加载”之后,数据在 Excel 中并没有完全流动。

Attached screenshot for your reference.附上截图供大家参考。 You can see data is loaded only for 32 rows.您可以看到仅加载了 32 行的数据。 However on the right side you can see that 430k+ rows are loaded但是在右侧,您可以看到加载了 430k+ 行

Combine files in Excel should be possible, but it's much easier done in a batch file.在 Excel 中合并文件应该是可能的,但在批处理文件中更容易完成。

see: Need to combine lots of files in a directory请参阅: 需要在一个目录中组合大量文件

and/or和/或

Windows batch - concatenate multiple text files into one Windows 批处理 - 将多个文本文件连接成一个

Try this尝试这个

Data ... Get Data .. From Other Sources ... Blank Query .... Advanced Editor ...数据 ... 从其他来源获取数据 ... 空白查询 .... 高级编辑器 ...

Paste below over everything in box将下方粘贴到框中的所有内容上

let Source = Folder.Files("C:\directory\subdirectory\"),
#"Filtered Rows" = Table.SelectRows(Source, each ([Extension] = ".csv")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Content", "Name"}),
CSVtoTable= Table.TransformColumns(#"Removed Other Columns", {{"Content", each Csv.Document(_)}}),
MaxColumns = List.Max(List.Transform(CSVtoTable[Content], each Table.ColumnCount(_))),
#"Expanded Content" = Table.ExpandTableColumn(CSVtoTable, "Content", List.Transform({1..MaxColumns}, each "Column" & Number.ToText(_)))
in #"Expanded Content"

Change row 1 to reflect the path where your files will be stored更改第 1 行以反映文件的存储路径

Hit 'Done'点击“完成”

What it does is它的作用是

(a) read in all files in your specified location (b) filter for CSV files (c) erase extra columns (d) Convert each CSV file into its own table (e) count how many columns the tables have so that we know how many columns to expand to (f) expand the tables (a) 读入您指定位置的所有文件 (b) 过滤 CSV 文件 (c) 删除多余的列 (d) 将每个 CSV 文件转换为自己的表格 (e) 计算表格有多少列,以便我们知道如何要扩展到 (f) 扩展表格的许多列

Complete any additional transformations you need then do Close And Load完成您需要的任何其他转换,然后执行 Close And Load

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM