cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dominono9
Advocate I
Advocate I

How convert text to datatable?

Hi 

 

I want to convert text to datatable

Please tell me how to do?

 

dominono9_0-1655610720460.png

↑ to ↓

dominono9_1-1655610766377.png

 

 

 

 

  

1 ACCEPTED SOLUTION

Accepted Solutions
AutomateWithDev
Regular Visitor

Hi @dominono9 

 

You can build a flow as shown below:

 

AutomateWithDev_5-1655665722587.png

 

Here, first I have created a data table with the column headers using the following expression in a 'Set Variable' action: 

 

%{ ^['Column 1', 'Column 2', 'Column 3'] }%

 

 

AutomateWithDev_8-1655665956476.png

 

 

Then, I split my text into a list with New Line as separator using a 'Split Text' action to create a list with each of the row elements in the text file:

 

AutomateWithDev_2-1655665530166.png

 

 

Next I iterate within this list element and the again use a 'Split Text' action for splitting the current row item with a comma separator:

 

AutomateWithDev_6-1655665773683.png

 

For each iteration I will get a list called as TextList as shown below:

 

AutomateWithDev_4-1655665649248.png

 

Now, in the end I just use a 'Set Variable' action again to add a new datarow consisting of all the items in the newly generated list to my original data table variable with the following expression:

 

 

%DataTable + [TextList[0], TextList[1], TextList[2]]%

 

AutomateWithDev_7-1655665928041.png

 

My final output is as shown below:

 

AutomateWithDev_9-1655665986335.png

 

 

 

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

If this post helps you with your problem, please mark your as Accepted solution. If you like my response, please give it a Thumbs Up.

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

View solution in original post

3 REPLIES 3
VJR
Super User
Super User

Use loops, string functions, split, etc on your textlist variable.

You have to form a string like %{ ^['ColumnName1', 'ColumnName2'], ['1', '2'], ['3', '4'] }%

 

And then pass it to Set variable

 

VJR_0-1655612691642.png

The output of this set variable will be a datatable

 

VJR_1-1655612739270.png

 

AutomateWithDev
Regular Visitor

Hi @dominono9 

 

You can build a flow as shown below:

 

AutomateWithDev_5-1655665722587.png

 

Here, first I have created a data table with the column headers using the following expression in a 'Set Variable' action: 

 

%{ ^['Column 1', 'Column 2', 'Column 3'] }%

 

 

AutomateWithDev_8-1655665956476.png

 

 

Then, I split my text into a list with New Line as separator using a 'Split Text' action to create a list with each of the row elements in the text file:

 

AutomateWithDev_2-1655665530166.png

 

 

Next I iterate within this list element and the again use a 'Split Text' action for splitting the current row item with a comma separator:

 

AutomateWithDev_6-1655665773683.png

 

For each iteration I will get a list called as TextList as shown below:

 

AutomateWithDev_4-1655665649248.png

 

Now, in the end I just use a 'Set Variable' action again to add a new datarow consisting of all the items in the newly generated list to my original data table variable with the following expression:

 

 

%DataTable + [TextList[0], TextList[1], TextList[2]]%

 

AutomateWithDev_7-1655665928041.png

 

My final output is as shown below:

 

AutomateWithDev_9-1655665986335.png

 

 

 

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

If this post helps you with your problem, please mark your as Accepted solution. If you like my response, please give it a Thumbs Up.

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

Thank you very much. I Understand!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,944)