Load data from Text file to Excel

I need to Read data in text file which has strings like below

image

Now i need to separate text and numbers and write into an excel where 1 row should have text and another row should have numbers.

Can someone help me on this?

1 Like

Hi
Welcome to uipath community
Hope these steps would help you resolve this
—use BUILD DATATABLE ACTIVITY and create a table structure with a single column of type string and get the output with a variable of type datatable named Finaldt
—then use CLEAR DATATABLE activity and mention the input as Finaldt
—use READ TEXT FILE activity and pass the file path text file as input
And get the output with a variable of type string named str_input
—now use a assign activity like this
arr_lines = str_input.Split(Environment.Newline.ToArray())

Where arr_lines is a variable of type array of string

—then use FOR EACH activity and pass the above variable as input and change the type argument as string in the property panel
—inside the loop use ADD DATAROW activity like this
With datatable as Finaldt and ArrayRow property as
{System.Text.RegularExpressions.Regex.Match(item.ToString,”[\d].+”).ToString}

And another add Datarow activity with same datatable Finaldt as input and arrayrow property as
{System.Text.RegularExpressions.Regex.Match(item.ToString,”[a-zA-Z].+”).ToString}

Cheers @harishkesavarapu

6 Likes

Hi @Palaniyappan
y u need to use clear datatable activity

we can mention only the build datatable activity and do the manipulations

Thanks
ashwin S

Yes of course we don’t need clear datatable activity
But sometimes when a datatable is created with Build datatable activity the first row is not deleted while creating
And that will reflect in our output datatable where the first row alone will be empty and rest will be added with data
That’s why to ensure that clear datatable activity if added we won’t have any empty rows in it
And only the table structure

Cheers @AshwinS2

2 Likes

@Palaniyappan @AshwinS2

Just to add some thoughts…
In the build data table activity designer… we actually see that default blank row as you guys already know… So, when designing, if we make sure that blank row is removed from the designer, we don’t need to clear the DT before adding data :slight_smile:

1 Like

Thanks @Palaniyappan, This solution worked for me.

1 Like

Cheers @harishkesavarapu

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.