cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vobius
Helper II
Helper II

Problem with array conversion / text file parsing

Hey all,

 

I want to convert some data from big text files (around 7200 lines) to usable variables so that I can get them into Sharepoint.

What I've done so far to try to achieve this is split the text file data so that all \n and \r are gone. 

After that I'm using Filter Array function to get the lines with the parameters I need. Now my problem begins: I want to extract specific values of the lines that I then want to use in Sharepoint / PowerApps. 

I use a replace, substring and sub function to get the correct keys and values in a Select. But my problem is: the output of the select function is an array where I have one object for each parameter.

This is how my Flow looks

vobius_1-1652942847526.png

 

I use the replace functions in the select action with the output of the filter action

Key = replace(substring(item(),lastindexof(item(),']'),sub(lastindexof(item(),'='),lastindexof(item(),']'))),']','')

Value = replace(substring(item(),indexOf(item(),'='),sub(length(item()),indexOf(item(),'='))),'=','')

 

This is the output I get:

vobius_0-1652942606796.png

 

My desired output would be to get something like this OR another, easier solution so that I can use my desired variables and put them into a SharePoint list.

 

[

  {

    "Terminal Name:" "Name",

    "Terminal Addr": "172....", 

    .....

  }

]

 

Many thanks in advance!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yujincui-msft
Community Support
Community Support

Hi @vobius ,

 

Do you want to rebuild this array?

I have made a test for your reference.

 

variables('orginalarray')[0]?['Terminal Name']
variables('orginalarray')[1]?['Terminal Addr']
variables('orginalarray')[2]?['Terminal Column']
[
  {
    "Terminal Name:": "@{variables('orginalarray')[0]?['Terminal Name']}",
    "Terminal Addr": "@{variables('orginalarray')[1]?['Terminal Addr']}",
    "Terminal Column": "@{variables('orginalarray')[2]?['Terminal Column']}"
  }
]

 

vyujincuimsft_1-1653285841783.png

Result Screenshot:

vyujincuimsft_2-1653286059838.png

 

 

Best Regards,

Charlie Choi

View solution in original post

2 REPLIES 2
v-yujincui-msft
Community Support
Community Support

Hi @vobius ,

 

Do you want to rebuild this array?

I have made a test for your reference.

 

variables('orginalarray')[0]?['Terminal Name']
variables('orginalarray')[1]?['Terminal Addr']
variables('orginalarray')[2]?['Terminal Column']
[
  {
    "Terminal Name:": "@{variables('orginalarray')[0]?['Terminal Name']}",
    "Terminal Addr": "@{variables('orginalarray')[1]?['Terminal Addr']}",
    "Terminal Column": "@{variables('orginalarray')[2]?['Terminal Column']}"
  }
]

 

vyujincuimsft_1-1653285841783.png

Result Screenshot:

vyujincuimsft_2-1653286059838.png

 

 

Best Regards,

Charlie Choi

vobius
Helper II
Helper II

Thank you very much, it worked as expected!

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.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,131)