How to pass data from Notepad to Excel

name1|1234|name1@gmail.com|Chennai
name2|1235|name2@gmail.com|Coimbatore
name3|1236|name3@gmail.com|Pollachi

the above is saved in a notepad, I wanna copy and paste this into an excel sheet. Name, number, email & city values should be split and written in each columns. Next record should go to second row. How to achieve this? Someone please help me on this.

1 Like

GI hope you can translate this into activities

Create a datatable with 3 columns.

string readText = File.ReadAllLines(“yourfile.txt”);
foreach(item in readText)
{
If (item<> string.empty)
{
Splititem= Split.string(item,“|”)

add data row activity here and in Array row property add “Splititem” and datatable variable in datatable.

}

}

Writerange to excel here

Could you please explain me little bit deeper. I am not from coding background.

1 Like

The first line reads a file “yourfile.txt” line for line and gives an array (a list) of strings (text-bits).

For each will go through these strings one at a time, and put each into a variable called item. This item will now represent the current line of text that we are working on.

Split.String(item, “|”) takes a string (item) and a split-string (“|”) and splits the first every time it finds the second.
The result of this is also a string with each column of the row you are manipulating.

Each of these can be referenced through Splititem[0], Splititem[1], etc.

The next thing you need to do is the code for actually writing to cells in an open spreadsheet.

1 Like

Hi I tried and stuck at reading split value and adding to data table, please help me out.
Main.xaml (26.6 KB)

@vvaidya
can you provide source code file

1 Like