cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GilesWalker
Skilled Sharer
Skilled Sharer

The Csv.Document parameter 'Columns' is invalid.

Hi everyone,

 

I am having the following issue on a couple reports I have built. So far the only options on the community forums is to either change from a personal gateway to an enterprise one (This isnt an option for me), the other is to change the CSV to a txt file. I have done this where I can however the report I am having issues with pulls CSV files from the new get data from a folder option. There doesnt appear to be a function within this to change the type to TXT.

 

Has anyone got a fix for this?

 

Thanks,

 

 

1 ACCEPTED SOLUTION

My IT department managed to fix the issue. We went through the advanced editor in query mode and manually changed the coding to get it to work.

 

This is how we did it:

 

This line of text is incorrect:

 

Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter=","columns=10, Encoding=1252]),

 

The columns=10 was counting the columns in the document (10 is correct) but something was going wrong. We deleted this text but lef tin the commas and republished the file. It then failed again due to this error:

 

The Csv.Document parameter 'QuoteStyle' is invalid. From memory the advanced editor text looked like this:

 

Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter=","columns=10, Encoding=1252]), QuoteStyle=QuoteStyle""

 

We deleted the QuoteStyle text and republished. The dashboard now refreshes using the automated refresh feature in Pro.

 

Thanks,

 

Giles

View solution in original post

18 REPLIES 18
noah-severyn
Advocate I
Advocate I

For anyone else who might come across this, I suspect that at least I ran into this issue because I created my query in a newer version of Power Query (Excel M365) and tried to run it in an older version of Power Query (Excel 2016). There was also at least one other function I had to remove parameters from, including Promote Headers.

LyndonJohnson
Regular Visitor

We found a solution by modifying the Csv.Document step as explained below. We encountered this same error in one of our solutions built in Power Query when a client updgraded from Excel 2013 to Excel 2016. The query was importing a CSV and was returning this error on the step that uses Csv.Document. It was and is still working correctly in Excel 2013, but was not working in Excel 2016.

 

The code that was returning the error was:
Csv.Document([Content],[Delimiter=",", Columns=40, Encoding=1252, QuoteStyle=QuoteStyle.None])

 

We changed it to the following:
Csv.Document([Content],[Delimiter=",", Column=40, Encoding=1252])

 

There were 2 changes, highlighted in red. Columns becomes Column (i.e. singular). This then no longer returns the parameter 'Columns' is invalid error message, but then returns an error message related to QuoteStyle. We then removed the QuoteStyle part. This then worked in Excel 2016. This code also works in Excel 2013 and in Power BI Desktop.

Hi Lyndon,

 

Thank you for your return !

 

How the quotations of a .CSV can be ignore as the "QuoteStyle=QuoteStyle.None" no longer works ?

 

For instance if I have the following csv file :

 

First name, gender, address

John, male, "1 Fox Street"

 

And I use : Csv.Document([Content],[Delimiter=",", Column=3, Encoding=1252])

 

The result looks like:

 

First name                       | gender | adress |

John, male, "1 Fox Street"|             |             |

 

Without the quotation

First name, gender, address

John, male, 1 Fox Street

 

The result looks like:

 

First name | gender | adress       |

John          |male      |1 Fox Street|

 

The quotations affect the result and there is no way to avoid them?

 

Best,

Kelian

 

Greg_Deckler
Super User IV
Super User IV

Can you post a sample of your CSV file that you are having trouble with, particular the column names and a row or two of data?


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Greg_Deckler

 

Here you go:

 

ConsignmentDocketDate LoadedDepotWagonProductGrossTareNetOvercarry
RA17221RA0031846112/04/2016 5:04010YTHFY015-N1306866.820.6546.151.65
RA17221RA0031846212/04/2016 5:03010YTHFY012-J1306866.920.546.41.35
RA17221RA0031846312/04/2016 5:09010YTHFY002130686719.6547.350

 

All the CSV files are the same, they have roughly 20 rows but the columns will never change. I have done a couple formatting changes to the files such as changing the date loaded column to be split into two columns date and time. The Wagon column is used to created a custom column which removes all the characters apart from the numbers.

 

Thanks,

 

Giles

@GilesWalker - Hmmm, I can't replicate it. I took your data and copied and pasted it into a file, wagons_tab.csv and then also created a true comma-separated file, wagons.csv, removed the tabs and replaced with commas. Both imported no problem using CSV as data source. Wasn't expecting that.

 

Um, what version of Power BI Desktop are you running?


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Greg_Deckler

 

Thats the same thing that happens to me. If I load a single file there is no issue. However some of my other reports had this same issue popping up in the last couple weeks. These are reports which have had no change made to them in over three months. The only fix was to have the individual CSV files data set changed through the settings features in query mode to a TXT file.

 

The feature to change the file type is not available in the get data FILE catagory. The CSV example I posted is one of over a 500 files contained within this file which grows everyday so no chance of manually changing the files to TXT.

 

Thanks,

 

Giles

Might warrant going here and opening an actual support case:

 

https://powerbi.microsoft.com/en-us/support/

 

Contact Support link.

 

Did you recently update your Desktop? 


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




My IT department managed to fix the issue. We went through the advanced editor in query mode and manually changed the coding to get it to work.

 

This is how we did it:

 

This line of text is incorrect:

 

Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter=","columns=10, Encoding=1252]),

 

The columns=10 was counting the columns in the document (10 is correct) but something was going wrong. We deleted this text but lef tin the commas and republished the file. It then failed again due to this error:

 

The Csv.Document parameter 'QuoteStyle' is invalid. From memory the advanced editor text looked like this:

 

Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter=","columns=10, Encoding=1252]), QuoteStyle=QuoteStyle""

 

We deleted the QuoteStyle text and republished. The dashboard now refreshes using the automated refresh feature in Pro.

 

Thanks,

 

Giles

View solution in original post

I'm having this same error, but am having difficulty performing the fix as you described.

 

When you say you deleted the text, what text did you delete? the '10' or the entire 'Columns=10'

 

This is my line of code as extracted from the Advanced editor

#"Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter="#(tab)", Columns=10 , Encoding=1200, QuoteStyle=QuoteStyle.None]),

 

So, my understanding of your suggestion is to replace with this:

#"Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter="#(tab)", , Encoding=1200, ]),

 

When I try that, I get teh error 'invalid identifier' so I know I'm not understanding right

@Caitlin_Knox

 

In your line of code:

 

#"Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter="#(tab)", Columns=10 , Encoding=1200, QuoteStyle=QuoteStyle.None]),

 

The items to delete are Columns=10 and QuoteStyle=QuoteStyle.None

 

The text below is what mine looks like and it appears as though you need to also delete "#(tab) and insert a " where the columns was.

 

Try and insert the text below to see if that works.

 

#"Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter=",", Encoding=1252]),

 

Thanks

 

Giles

When I applied those changes in the Advanced Editor I get a new error

'Expression.Error: The column 'User(Login Name' of the table wasn't found.'

 

This is a column that was removed when I was 'grooming' the data after the binaries were combined. I have opened a ticket with Microsoft, but they don't really know what is going on either.

@Caitlin_Knox

 

Are you able to send through all the text in the advanced editor or a screen shot?

let
    Source = Folder.Files("C:\Users\CaitlinKnox\SharePoint\LifeCycle Reports - SPU"),
    #"Filtered Rows2" = Table.SelectRows(Source, each ([Extension] = ".csv")),
    #"Combined Binaries" = Binary.Combine(#"Filtered Rows2"[Content]),
    #"Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter="#(tab)", Columns=10, Encoding=1200, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV"),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"User (Login Name)", type text}, {"User", type text}, {"URL", type text}, {"Type", type text}, {"Action", type text}, {"Time", type datetime}, {"Details", type text}, {"", type text}, {"_1", type text}, {"_2", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [User] <> null and [User] <> ""),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Details", "", "_1", "_2", "User (Login Name)"}),
    #"Filtered Rows1" = Table.SelectRows(#"Removed Columns", each ([User] = "Broker Associate Level - The NT Group - Joe Nemastil" or [User] = "Broker Executive Level - Nology - Brendon Liner" or [User] = "Broker Master Level - Integrated - Mary Heinen" or [User] = "Broker Professional Level -  Millermiller Industrial Solutions - Karl Miller" or [User] = "Broker Professional Level - Muhammad Alam" or [User] = "Broker Professional Level - TechNoir - James Velco" or [User] = "Broker Professional Level - USPCNET - Elias Kousoulas" or [User] = "Greg LaCoste" or [User] = "Heather Raymond" or [User] = "Joellyn Mayer" or [User] = "John Kennedy" or [User] = "Morgan Spencer" or [User] = "Scott Morgan")),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Filtered Rows1","URL",Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv),{"URL.1", "URL.2", "URL.3", "URL.4", "URL.5", "URL.6", "URL.7", "URL.8", "URL.9", "URL.10", "URL.11"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"URL.1", type text}, {"URL.2", type text}, {"URL.3", type text}, {"URL.4", type text}, {"URL.5", type text}, {"URL.6", type text}, {"URL.7", type text}, {"URL.8", type text}, {"URL.9", type text}, {"URL.10", Int64.Type}, {"URL.11", type text}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Changed Type1",{"URL.1", "URL.2", "URL.3", "URL.5", "URL.9", "URL.10", "URL.11"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Removed Columns1","URL.8",Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv),{"URL.8.1", "URL.8.2", "URL.8.3", "URL.8.4"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"URL.8.1", type text}, {"URL.8.2", type text}, {"URL.8.3", type text}, {"URL.8.4", type text}}),
    #"Merged Columns" = Table.CombineColumns(#"Changed Type2",{"URL.8.1", "URL.8.2", "URL.8.3"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"URL"),
    #"Removed Columns2" = Table.RemoveColumns(#"Merged Columns",{"URL.8.4"})
in
    #"Removed Columns2"

@Caitlin_KnoxTry this and see if it works, i have removed some information and changed the coding from 1200 to 1252. 1252 is the encoding of characters to English. 

 

let
    Source = Folder.Files("C:\Users\CaitlinKnox\SharePoint\LifeCycle Reports - SPU"),
    #"Filtered Rows2" = Table.SelectRows(Source, each ([Extension] = ".csv")),
    #"Combined Binaries" = Binary.Combine(#"Filtered Rows2"[Content]),
    #"Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter=", ", Encoding=1252]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV"),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"User (Login Name)", type text}, {"User", type text}, {"URL", type text}, {"Type", type text}, {"Action", type text}, {"Time", type datetime}, {"Details", type text}, {"", type text}, {"_1", type text}, {"_2", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [User] <> null and [User] <> ""),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Details", "", "_1", "_2", "User (Login Name)"}),
    #"Filtered Rows1" = Table.SelectRows(#"Removed Columns", each ([User] = "Broker Associate Level - The NT Group - Joe Nemastil" or [User] = "Broker Executive Level - Nology - Brendon Liner" or [User] = "Broker Master Level - Integrated - Mary Heinen" or [User] = "Broker Professional Level -  Millermiller Industrial Solutions - Karl Miller" or [User] = "Broker Professional Level - Muhammad Alam" or [User] = "Broker Professional Level - TechNoir - James Velco" or [User] = "Broker Professional Level - USPCNET - Elias Kousoulas" or [User] = "Greg LaCoste" or [User] = "Heather Raymond" or [User] = "Joellyn Mayer" or [User] = "John Kennedy" or [User] = "Morgan Spencer" or [User] = "Scott Morgan")),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Filtered Rows1","URL",Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv),{"URL.1", "URL.2", "URL.3", "URL.4", "URL.5", "URL.6", "URL.7", "URL.8", "URL.9", "URL.10", "URL.11"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"URL.1", type text}, {"URL.2", type text}, {"URL.3", type text}, {"URL.4", type text}, {"URL.5", type text}, {"URL.6", type text}, {"URL.7", type text}, {"URL.8", type text}, {"URL.9", type text}, {"URL.10", Int64.Type}, {"URL.11", type text}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Changed Type1",{"URL.1", "URL.2", "URL.3", "URL.5", "URL.9", "URL.10", "URL.11"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Removed Columns1","URL.8",Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv),{"URL.8.1", "URL.8.2", "URL.8.3", "URL.8.4"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"URL.8.1", type text}, {"URL.8.2", type text}, {"URL.8.3", type text}, {"URL.8.4", type text}}),
    #"Merged Columns" = Table.CombineColumns(#"Changed Type2",{"URL.8.1", "URL.8.2", "URL.8.3"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"URL"),
    #"Removed Columns2" = Table.RemoveColumns(#"Merged Columns",{"URL.8.4"})
in
    #"Removed Columns2"

2016-04-14_16-57-14.jpg

 

I get the error 'Token Comma expected' When I click show error, it highlights the text as shown in the screen capture. But looking at the lines around, I cant determine where it is expecting a comma.

@Caitlin_Knox

 

This happened to me also. By changing the inormation in the first couple steps this can then have an effect on the remaining steps. Is it possible for you in the query editor to remove all steps after the promoted headers step? Then see what the data looks like and go through and do your editing again?

@Caitlin_Knox

 

This happened to me also. By changing the inormation in the first couple steps this can then have an effect on the remaining steps. Is it possible for you in the query editor to remove all steps after the promoted headers step? Then see what the data looks like and go through and do your editing again?

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Top Kudoed Authors