# Read and split data from excel

**URL:** <https://forum.uipath.com/t/read-and-split-data-from-excel/562903>\
**Category:** Studio\
**Tags:** studio, excel, activities\
**Created:** [July 13, 2023, 4:11am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903 "2023-07-13T04:11:36Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinash.wankhede](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@avinash.wankhede](https://forum.uipath.com/u/avinash.wankhede)\
**Post date:** [July 13, 2023, 4:11am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/1 "2023-07-13T04:11:36Z")

</div>

I have to read the excel file which Cell has for ex: - Outlook Email

I want to read **only 1st** word after the - i.e Outlook in this example

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [July 13, 2023, 4:18am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/2 "2023-07-13T04:18:05Z")

</div>

@avinash.wankhede

For reading the cell value you can use read cell activity

And then to extract the required value, say the cell value read is stored in str then

`System.Text.RegularExpressions.Regex.Match(str,"(?<=-\s+)\w*").Value`

 ![IMG_6026](https://global.discourse-cdn.com/uipath/original/4X/4/a/f/4af6f818325e2349e74f77c519c91ca62490462d.jpeg)

Cheers

---

<div class="post-metadata">

**Author:** ![mkankatala](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mkankatala/32/484097_2.png) [@mkankatala](https://forum.uipath.com/u/mkankatala)\
**Post date:** [July 13, 2023, 4:22am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/4 "2023-07-13T04:22:07Z")

</div>

Hi @avinash.wankhede

Store the Outlook Email in a string variable like Variable

```auto
Assign -> Variable = "Outlook Email"
Assign -> Variable = Variable.split(" ").First

```

In this i used split function to split the two words by using the space and took the first one.  
Check the below image for better understanding

 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/b/e/abea5b5c57052c7257c80f0b59d61f774ff7086d.png)

If you want to take the Email from Outlook Email use the below one

```auto
Assign -> Variable = Variable.split(" ").Last

```

 ![image](https://global.discourse-cdn.com/uipath/original/4X/e/3/5/e35c9d74c4c751dd7269ab7999c5ec0c8c43e47f.png)

Hope it helps!!

---

<div class="post-metadata">

**Author:** ![rlgandu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rlgandu/32/488436_2.png) [@rlgandu](https://forum.uipath.com/u/rlgandu)\
**Post date:** [July 13, 2023, 4:23am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/5 "2023-07-13T04:23:08Z")

</div>

@avinash.wankhede  
Hi,  
Use read range  
In for each loop take assign Content=CurrentRow(“ColumnName”).ToString  
System.Text.RegularExpressions.Regex.Match(str,“(?\<=\w+\s+).\*”).Value

---

<div class="post-metadata">

**Author:** ![Parvathy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/parvathy/32/484539_2.png) [@Parvathy](https://forum.uipath.com/u/Parvathy)\
**Post date:** [July 13, 2023, 4:23am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/6 "2023-07-13T04:23:13Z")

</div>

Hi @avinash.wankhede

Use the following regex expression:

```auto
System.Text.RegularExpressions.Regex.Match("Outlook Email","[\w]+(?=\s)").Value
Output: Outlook

System.text.RegularExpression.Regex.Match("your string Input","(?<=\s)[\w]+").Value
Output: Email

```

 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/2/f/32f8b8020a50a8d763ba82c487ded88417e44091.png)  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/e/5/3e57bb95ad999456a6229f1187e103e1e845862d.png)

Hope it helps!!  
Regards,

---

<div class="post-metadata">

**Author:** ![Gokul\_Jayakumar](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gokul_jayakumar/32/425938_2.png) [@Gokul\_Jayakumar](https://forum.uipath.com/u/Gokul_Jayakumar)\
**Post date:** [July 13, 2023, 4:31am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/7 "2023-07-13T04:31:21Z")

</div>

Hello @avinash.wankhede  
To read the Specific Cell, you can use the read cell activity and store the value in a variable.  
By using Regex you can achieve your requirement.

```auto
System.text.RegularExpression.Regex.Match(ReadCellStr,"(?<=-\s)[A-Za-z.0-9]+").Tostring.trim

```

 ![image](https://global.discourse-cdn.com/uipath/original/4X/c/5/6/c561776ff17e0f5553f1bf010eadf7d515b41d12.png)

---

<div class="post-metadata">

**Author:** ![avinash.wankhede](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@avinash.wankhede](https://forum.uipath.com/u/avinash.wankhede)\
**Post date:** [July 13, 2023, 5:33am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/8 "2023-07-13T05:33:21Z")

</div>

currentItem.ToString().Split(“-”)(1)

with this I am spliting the - and reading the enitire text after that - i.e outlook email.

I need only OUTLOOK word

---

<div class="post-metadata">

**Author:** ![mkankatala](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mkankatala/32/484097_2.png) [@mkankatala](https://forum.uipath.com/u/mkankatala)\
**Post date:** [July 13, 2023, 5:35am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/9 "2023-07-13T05:35:26Z")

</div>

Use the split like this  
CurrentItem.ToString.Split(" ")(1)

Could you please which have to be take to extract the outlook. Please give the exact text with in double quotes

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [July 13, 2023, 5:38am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/10 "2023-07-13T05:38:08Z")

</div>

@avinash.wankhede

Store the Outlook Email to a variable.

```auto
Word = "Outlook Email"
Reuqired Data = Word.Split(" "c)(0)

```

Regards

---

<div class="post-metadata">

**Author:** ![avinash.wankhede](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@avinash.wankhede](https://forum.uipath.com/u/avinash.wankhede)\
**Post date:** [July 13, 2023, 5:38am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/11 "2023-07-13T05:38:25Z")

</div>

“2023 - Outlook Email” is there but from here I need only Outlook

---

<div class="post-metadata">

**Author:** ![mkankatala](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mkankatala/32/484097_2.png) [@mkankatala](https://forum.uipath.com/u/mkankatala)\
**Post date:** [July 13, 2023, 5:39am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/12 "2023-07-13T05:39:43Z")

</div>

Okay then

```auto
Assign -> Variable = "2023 - Outlook Email"
Assign -> Variable = Variable.split(" ")(2)

```

You can use the below regex expression too  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/6/6/366bf79bb3ed2176541b1d7357baabc2df8a804d.png)

---

<div class="post-metadata">

**Author:** ![rlgandu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rlgandu/32/488436_2.png) [@rlgandu](https://forum.uipath.com/u/rlgandu)\
**Post date:** [July 13, 2023, 5:40am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/13 "2023-07-13T05:40:11Z")

</div>

Hi  
(?\<=-\s\*)[A-Z]+[a-z]+(?=\s)

Thanks

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [July 13, 2023, 5:40am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/14 "2023-07-13T05:40:26Z")

</div>

> [@Anil\_G](#):
>
> System.Text.RegularExpressions.Regex.Match(str,“(?\<=-\s+)\w\*”).Value

@avinash.wankhede

Please try this…this would work as you need

cheers

---

<div class="post-metadata">

**Author:** ![lrtetala](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@lrtetala](https://forum.uipath.com/u/lrtetala)\
**Post date:** [July 13, 2023, 5:41am UTC](https://forum.uipath.com/t/read-and-split-data-from-excel/562903/15 "2023-07-13T05:41:13Z")

</div>

Hi @avinash.wankhede

Try this  
`Valg.Split("-"c)(1).Split(" ")(1)`

 ![image](https://global.discourse-cdn.com/uipath/original/4X/6/6/4/664db8e6e6d4ebe423bd1ecb54e191ccada246c6.png)
