Concatenation

Hi everyone, I am a baby coder

I am trying to build an internal office solution with UIPath that requires me to change the parameters below into variables.
I don’t know how to convert the day, month, and year in the string below into variables without getting an error.
I would love some help on getting it done, and an understanding of why I am finding it hard to figure out.

Here is the task:
I have defined two variables:
filename = “C:\Users\YINKA\Downloads\Bp_08_19_2020.csv”
sheetname = “Bp_08_19_2020”

As you can see, they are both dates. How do I make the dates variable so that when I conduct the exercise on 08/29/2020, these variables are renamed to 08_29_2020 or any date I choose to run the program?

Thanks in advance, Gurus!

1 Like

Hello

Plenty of bigger gurus than me but could you use the string.replace method?

Step 1:
sheetname.Replace(“/”, “_”)

Step 2:
Then in an assign activity:
Sheetname = “Bp_” + Sheetname

I am sure you will have another solution soon.
Check out @Adrian_Star’s mega post:

Cheers

Steve

Check this below workflow, @ydaramola
Change_Date_Representation.xaml (5.1 KB)
Hope this may help you :slight_smile:

Thank you very much gurus @Steven_Mckeering! and @Manish540. I have used your ideas and contributions to shorten my program. It works pretty good, but I am still stuck at the point where I have to
get UIPath to understand that “‘C:\Users\YINKA\Downloads'+sheetname+’.csv’” refers to the changing filename. It does not understand that. So I am probably not concatenating right, most likely.

1 Like

Thank you very much gurus @Steven_Mckeering! and @Manish540. I have used your ideas and contributions to greatly shorten my program. It works pretty good, but I am still stuck at the point where I have to get UIPath to understand that “‘C:\Users\YINKA\Downloads'+sheetname+’.csv’” refers to the changing filename. It does not understand that. So I am probably not concatenating right, most likely.

1 Like

Hello again

Glad I could assist a little.

Do you need another “\” after downloads?

Post an image of the error if you can.

Cheers

Steve

Hi @ydaramola

I think it should be like this.

“C:\Users\YINKA\Downloads"+sheetname+”.csv"

Regards
Anand

@anandji05 Shukriya. I tried that. But when I do that it names the workbook “Downloads” and places it in a different folder entirely. This is not what I need. I need it to go to the Downloads folder and retrieve a workbook named “Bp_08_30_2020 .csv”
The sheet’s name changes everyday.

@Steven_McKeering, @anandji05, @Manish540 I tried that, it didn’t work.
Maybe I should shed more light:
Problem statement: I made a robot program that goes to an online database and downloads an excel sheet containing health data. It downloads the file to my downloads folder and names it Bp_08_30_2020.csv.
Inside the csv file, there is a worksheet already named 08_30_2020 from the online database. It is important to note that the filename changes every day to match with the current date.
So, let today’s date= ccdate = 08_30_2020
sheetname = Bp_08_30_2020
or to convert it to variable form, sheetname = “Bp_”+ccdate
therefore filename = ““C:\Users\YINKA\Downloads\Bp_”+ccdate+”.csv""
OR filename = ““C:\Users\YINKA\Downloads"+sheetname+”.csv”"
I don’t understand why it is not working.

Why are you not assigning value like this
“C:\Users\YINKA\Downloads\Bp_”+ccdate+”.csv"

OR filename = “C:\Users\YINKA\Downloads”+sheetname+”.csv"

Can you send me some screenshots?

Regards
Anand

Hi @anandji05. I tried both, but I get the errors shown in the attachments. It does not seem to add on the ccdate variable when naming the csv file, so the program fails.

Using the other option, it saves a file named Downloads inside an entirely different folder, because there is not slash after Download. Screenshots attached.

err4

Hi

Can you send me the code screenshots where you are assigning this value?

Regards
Anand

Hi Anand

I have attached them. When I use a message box to try out the sheetname, it only shows as Bp_.

Hi @ydaramola are u using current date to save file

Nived N :robot:

Hi

Why are you not using assignment activity for assigning variable.Put String variable in variable pan as default and take assignment activity for string manipulation.Main.xaml (4.6 KB)

Regards
Anand

Hi Anand! Your suggestion worked! Bakut Shukriya!
I wonder… why do we have to assign it to the variable before it works? Can’t we just create a variable and define the default value and get the same result? I find that a little confusing. Thanks again!

:+1:

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