Forum Discussion

rpmm's avatar
rpmm
Regular Visitor
3 years ago

Adjust columns in csv before combining?

I have a folder full of csv files which I am currently combining by adding a folder as a data source. The files are exports from an order report (files are by month and year). For 2022, the order report has one extra column so when I refresh I get an error:

OLE DB or ODBC error: [DataFormat.Error] There were more columns in the result than expected..
 
I understand this error is because there is a new column in the 2022 file, but because I am doing a combine from a folder, I can't find a way to handle that extra column before combining all the csv files. 
 
Any other idea on how I can handle this situation? 

6 Replies

  • menglaro78's avatar
    menglaro78
    Icon for Microsoft Employee rankMicrosoft Employee

    Hello,
    if you used Folder as your data source, surely Power Query created the structure to combine the data.
    In doing so, it creates the sample transformation based on the first file it finds in the folder.
    That's the place to add your new column and get it over to the rest of the Power Query.


    Marco

    • rpmm's avatar
      rpmm
      Regular Visitor

      I don't see the helper queries on the left. I only see the main query which does not have a place to set the combination sample file. 

  • Hi rpmm ,

    from this window, instead of choosing the first file as sample, choose one of the files that have the maximum number of columns.

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • rpmm's avatar
      rpmm
      Regular Visitor

      I don't see this window. Is it because my files are being combined as Binary? 

      • menglaro78's avatar
        menglaro78
        Icon for Microsoft Employee rankMicrosoft Employee

        The photo shown by mangaus1111 you see it only when the first time you select the folder as a data source.

        Is it possible share your file ?

         

        Marco