Making Column Count dynamic (not the names but the number of columns)

mcharing

New member
Joined
Jan 11, 2017
Messages
2
Reaction score
0
Points
0
Location
Nijmegen, Netherlands
Website
www.bisqq.nl
Hi,

I am currently using CSV files that are exported from a firebird database. 1 CSV file represents 1 table in the firebird database.

When I connect to the CSV file in Power Query the number of columns is hard-coded. This is no problem for now but when the original tables are being changed (most likely is that extra columns are being added) Power Query will only import the original amount of columns when I first imported the CSV file.

dynamic columns for CSV.PNG


can someone help me with creating a dynamisch columncount that is futureproof for extra columns?

I have tried to count the columns of the CSV in a list and a table but I don't know what to do with it at this point.

dynamic column count to list.PNGdynamic column count to table.PNG

Mark Haring
BisQQ
 
Last edited:
Just remove the columns limitation from the code.

Hard Coded Script:

= Csv.Document(File.Contents("U:\MISC.CSV"),[Delimiter=",", Columns=228, Encoding=1252, QuoteStyle=QuoteStyle.None])

FIX:

Yes, but it's not about dynamically changing as much as it is actually removing the part that hard codes the columns:


= Csv.Document(File.Contents("U:\MISC.CSV"),[Delimiter=",", Encoding=1252, QuoteStyle=QuoteStyle.None])
 
Thanks El cid!!

Your solution works fine. Now I am future proof on this issue.

One remaining question in the back of my head; Why does the Power Query team insert it hard-coded in the first place? do I need it for a functionality somewhere else?
 
That's the default setting because through the GUI you first selected the columns you wanted to change.
 
Back
Top