Line break causing issues combining .csv file with comma delimiter

Rosie_222

New Member
Joined
Apr 19, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hey All,

Ran into a problem this week and I'm curious if anyone knows why it occurs, plus if there's a simpler way to fix it than what I had in mind. I work in marketing and use excel power query and power pivots to summarise our data (they're amazing for this). I'll frequently use power query to get and combine multiple .csv files in a sharepoint folder, this makes it easy for me to update the data set daily.

Recently I encountered an error where some data was entering as a new row when it should have been part of the previous row and was therefore ending up with data in the wrong columns etc. On investigation I found this wasn't due to a badly placed comma outside of "" but instead due to a cell which contained a line break. This cell contained text as below:

"TEXT | TEXT | TEXT
"

When I use the combine feature I'm determining the delimiter as a comma so I'm not sure why this occurs and would love to understand it better.

1697196404949.png


I came across a potential solution where you change the delimiter so the data reads into one cell, allowing me to remove the line break in the specific example above before splitting by the delimiter. It's likely that the data with the line break will keep cropping up so ideally I want to build a fix into the steps but I can't help thinking there must be an easier way? If not, does anyone know how to represent a line break in the M code?

Happy to share more details if needed!

Thanks,
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
In Power Query M code, you can represent a line break or newline character using the #lf or #(10) escape sequence. Here's how you can use it:

let
myText = "This is line 1.#lfThis is line 2."
in
myText

In the above code, #lf or #(10) represents a line feed character, which is typically used for line breaks in text. You can use this within your M code to insert line breaks or newlines wherever needed, such as within text strings or comments. When you use this code to load data or create custom columns in Power Query, the line breaks will be respected.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top