cancel
Showing results for 
Search instead for 
Did you mean: 

Python script split table by end of lines (\n)

I have following issue trying run python script:

This is json to read:

{
  "startAt": 0,
  "maxResults": 5000,
  "maxResultsLimit": 5000,
  "total": 409,
  "values": [
    {
      "Id": "some-code-12321",
      "title": "Some Title",
      "some messages": [
        "something\nsomething",
        "something\nsomething"
      ],
     }
			]
}

This is Query:

let
    Source = Json.Document(File.Contents("path_to_json")),
    #"Converted to Table" = Record.ToTable(Source),
    Value = #"Converted to Table"{4}[Value],
    #"Converted to Table1" = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column2" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"Id", "title", "some messages"}, {"Id", "title", "some messages"}),
    #"Extracted Values1" = Table.TransformColumns(#"Expanded Column2", {"some messages", each try Text.Combine(List.Transform(_, Text.From), " ") otherwise _, type text}),
    #"Run Python script" = Python.Execute("# 'dataset' holds the input data for this script#(lf)",[dataset=#"Extracted Values1"]),
    dataset = #"Run Python script"{[Name="dataset"]}[Value]
in
    dataset

And here is output:

image.png

Of course output should looks like input, because python script didn't do anything so something is wrong.

Status: Accepted
Comments
Moderator

Hi @michalplat

 

I have reported this issue internally: CRI 153737976. Will update here once I get any information. 

 

Best Regards,
Qiuyun Yu 

Moderator
Status changed to: Accepted
 
Moderator

Hi @michalplat

 

I got information that "The fix will be shipped with upcoming releases of PBI DesktopAs a mitigation, if customer also has , or " character inside the string, it won't be split anymore. "

 

Best Regards,
Qiuyun Yu

 

Frequent Visitor

Thank You for Your support. Do You know when exactly the fix will be shipped?

Moderator

Hi @michalplat

 

It should be coming with November Power BI desktop.

 

Best Regards,
Qiuyun Yu