Creating list of strings from datatable

Basically what I need is to make one of the columns of my excel spreadsheet into a list of strings and I can’t seem to do it! Please help!!

Hi @Olivia_Winter

Welcome to uipath community

yes of course we can do that
–use a excel application scope and pass the file path as input
–use a read range activity and get the output with a datatable variable named outdt
–create a variable named out_list of type list (of string) in the variable panel with the default value as new list(of string)
–use a for each row loop and pass the datatable variable as input outdt
–inside this loop use a activity called add to collection
and in item mention as row(“yourcolumnname”).tostring
and in collection mention as out_list
this will add all the values in that column to that list
Hope this steps would help you
Kindly try this and let know for any queries or clarification
Cheers @Olivia_Winter

3 Likes

I’m clearly doing something wrong here because i just can’t get out_list to be a list of string and get the default value to be new list(of string) without that blue bloody sign popping up and telling me that its a compilers error! Please help me :slight_smile:

1 Like

can i have a screenshot of that error
actually it should be like

variable name : out_list
type : System.Collections.Generic.List(of string)
scope : yoursequencename
default : new list (of string)

Cheers @Olivia_Winter

3 Likes

Change the variable type to a list<string> variable that i’ll call StrList. In an assign activity put in: StrList = new list(of string)

2 Likes

Hi @Olivia_Winter

For your reference hope this might be helpful to you.

cheers :smiley:

Happy learning :smiley:TestData.xlsx (7.4 KB)

1 Like

This is what I can see and this is what I was seeing before I came on here! I’m new to UiPath so I’m probably doing something stupid, but I don’t know what that stupid thing is :joy::joy:

2 Likes

Hello @Olivia_Winter alternatively you can try below as well…

Read your excel in to datatable dt

List<String> ListStr = (From rw in dt select x = rw("ColumnName").tostring).ToList
2 Likes

I believe the issue is with data type of variable out_list. It is of type Generic instead List<string>

2 Likes

I’ve tried, but I can’t! I don’t know what this means and honestly I’m close to throwing my laptop out the window

1 Like

can you upload your xaml please

2 Likes

ROBOT PRACTICE RUN.xlsx (9.7 KB)
This is the fake one I’ve created to use when setting up the robot

1 Like

give us XAML file not excel file…

2 Likes

Main.xaml (7.1 KB)

2 Likes

Hello @Olivia_Winter
There were two mistakes in your workflow one you were trying to create of list of array of string and second you did’nt change the datatype to list
Main (11).xaml (7.2 KB)

2 Likes

HI @Olivia_Winter
you were almost done
no worries
the reason were
Creation of list variable in the variable panel out_list and it should be like with type
system.Collections.Generic.List(of string)
keeping the scope of the variable outdt with whole sequence
–Then the next one is out_list initialization it should be new list (of String)

–then finally changing the type argument of add to collections to string


here you go with the resolved xaml
oliv.zip (16.7 KB)

hope its resolved
Cheers @Olivia_Winter

2 Likes

so any other stuffs to be discussed
were we able to accomplish this
Cheers @Olivia_Winter

1 Like

Hi @Olivia_Winter

Dont throw it…dont loose hope. A lot of hepful people here in our community if you have a problem in uipati just raise it here…we are happy to help.

cheers

Happy learning

Please help

Capture1

2 Likes

hi @Olivia_Winter

can you upload your xaml ?

cheers :smiley:

Happy learning :smiley: