Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
good afternoon people. I'm trying to load a .CSV file through power query. In this file, the first 3 lines are the header, separated by a comma, and the rest are the records. However, despite having only 3 headers, in the records of lines 4, 6, 8 and 11, I have an extra comma. This should generate another column, but my power query is only considering 3 columns. Even when I change the delimiter to "space", only the 3 columns are considered. Can anyone know what could be happening?
My guess is the number of columns was hardcoded as '3' when the file was imported.
You can verify this by looking in the code line for the source step or in the 'Advanced Editor' and you should see something like...
Csv.Document(File.Contents("C:\pathToFile\TESTFILE.csv"), [Delimiter=",", Columns= 3])
If you have a fixed number of columns expected you can change the '3' to the number you expect. If the number of columns will change over time you can use a code like the following in the 'Advanced Editor'...
let
getMaxColumnSize = List.Max(List.Transform(Csv.Document(File.Contents("C:\pathToFile\TESTFILE.csv"),1, ",", ExtraValues.List)[Column1], each List.Count(_))),
Source = Csv.Document(File.Contents("C:\pathToFile\TESTFILE.csv"),getMaxColumnSize, ",")
in
Source
Proud to be a Super User! | |
User | Count |
---|---|
11 | |
7 | |
5 | |
5 | |
4 |
User | Count |
---|---|
16 | |
14 | |
8 | |
6 | |
6 |