Forum Discussion

Goodkat's avatar
Goodkat
Helper II
1 year ago
Solved

csv file column count parameter issue with tab / semicolon separator

Dear Power Query enthusiasts, Yesterday I came across a topic I could not resolve with intense search on various forums. I have a csv file with 'tab' as delimiter. When I Import it, the numbe...
  • MFelix's avatar
    MFelix
    1 year ago

    Hi Goodkat ,

     

    The question about your files and when you remove the column numbers is related with the first row of your file.

     

    In the TAB one you have the 2025 being in the end of the line with a tabe for each of the columns. Not sure if it's visible on this image but you can check the indentation on the first line:

    So it does not matter if you have the number of columns or not because there are the correct number of separators in the first line. If you delete all the tabs in the first row you will see that the final result will be a single column:

     

     

     

     

    When you get to the semicolon this is not what is happening:

    You can see that there is only a semicolon in the first row so it splits by 2 when you remove the column number.

     

    In both cases if you want to make sure you have the correct number of columns you must:

    • Connect to the CSV
    • Select a separator that is not on the file

     

    • Remove the top 2 rows

    • Split columns by delimiter
    • Promote headers

    Be aware that this option will also hard code the number of columns because of the column names that will be hard coded into that specific function. You can try and write some specific function to get a dynamic number of columns based on the number of semicolon or tab or whatever other separator.