-2

I'm trying to consolidate data from multiple csv files in excel sheet using Data-. New Query-.From File option.

However after doing "Combine and Load" data is not flowing completely in Excel.

Attached screenshot for your reference. You can see data is loaded only for 32 rows. However on the right side you can see that 430k+ rows are loaded

2 Answers2

1

Combine files in Excel should be possible, but it's much easier done in a batch file.

see: Need to combine lots of files in a directory

and/or

Windows batch - concatenate multiple text files into one

Luuk
  • 4,913
  • 3
  • 17
  • 21
0

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

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

Complete any additional transformations you need then do Close And Load

horseyride
  • 3,233
  • 1
  • 5
  • 11