How can we check a specific language month names in an excel filename?

Hi All,

I will be getting excel files every month in which spanish language month names will be added.
For e.g. Employee Details junio 2021.xlsx and I need to process these excel files in next month
June month file will get processed in July month.
How can I check for spanish month names from a file name in a folder?

Please Help.

Hi @Poonam_Yadav,

  1. Get all the files from a folder using Directory.GetFiles(FolderPath)
  2. Use for each activity to get the file name Path.GetFileName(FilePath)
  3. Use Regular expression to get the month name from the filename string
  4. You can use a mapping file or you can use the language translator to convert the spanish to english

Regards,

1 Like

Hi @Poonam_Yadav

Refer to the xaml below!

Main.xaml (7.4 KB)

Regards

Hi @Poonam_Yadav ,

We can Convert the Current Language Month Name to a Spanish Name using the Culture Info.

As you would need to get the Previous Month Name in Spanish, The Culture Info Code would be es-ES.

We can get the Converted Month Name as below :

Now.AddMonths(-1).ToString("MMMM",System.Globalization.CultureInfo.GetCultureInfo("es-ES"))

We can use this Code in the Directory.GetFiles method of accessing the files as below :

Directory.GetFiles("YourFilePath","*"+Now.AddMonths(-1).ToString("MMMM",System.Globalization.CultureInfo.GetCultureInfo("es-ES"))+"*")

Here is a List of Culture Info or Country Codes for the Culture Info :

3 Likes

Hey @Poonam_Yadav! Lets go to the solution!

  • Step 1: We are going to define a variable of type CultureInfo “culture” that will contain our Spanish culture information.

  • Step 2: Let’s now define the date of Today and store it in a variable of type Datetime “date_today”, this is because we are going to extract from this variable the desired month (current month -1)

  • Step 3: Let’s define a String array that will contain the files of interest that we are going to return.

  • Step 4: And finally we will have a variable of type String “str_lastMonthSpanish” that will store month-1 in Spanish in full.

Now let’s get to the code!

  • Step 5: First let’s extract the name of the month in Spanish.
date_today.AddMonths(-1).ToString("MMMM", culture).ToLower

  • Step 6: Next we will extract the files that have month-1 in Spanish in their name.
System.IO.Directory.GetFiles("C:\Users\gabriel.ribas\Desktop","*.xlsx").Where(Function(f) System.IO.Path.GetFileNameWithoutExtension(f).ToLower.Contains(str_lastMonthSpanish)).ToArray

Hope it helps!!

The .xaml
Main.xaml (8.9 KB)

3 Likes

Hi, I’m also having issues with culture info but, in my case, the issue appears when trying to convert the date that I’m reading with the robot.

  1. I read my date from an excel using an “Assign” activity, I assign “Excel_Historico.Sheet(Nombre_Hoja_En_Excel_Historico).Cell(“A2”).ToString” to my variable string “UltimoMovimiento_FechaValor”.

  2. I try to convert the date in order to calculate or compare dates, so I try to assign “DateTime.ParseExact(UltimoMovimiento_Fecha.Replace(“00:00:00”,”“).trim,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)” to the date variable “UltimoMovimiento_FechaValor_FormatoFecha”.

It worked perfectly in my computer, but when I published the automation for my finances collegue, in her computer she’s having this error:

How can I manage for my robot can work in both computers with both languages?

we would recommend to open a new topic for your case and get individually support

also have a look here:
:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

Issue looks more about the swapped day / month part as 13/11/2023 is not in format

and with this pattern is is correctly complaining a 13th Month

I finally solved my issue, but this is always complex to manage diferent cultures, if this is a bit complex for me…I can’t imagine what it is for non-informatic users, they become mad with this and this is a basic need to automate, even the most simplest process can need more or less complex dates management.

Why UiPath don’t develops language-culture input and output properties and multi-language functionnalities for activities? (for example, also for selectors, to be able to develop for the same page in multiple languages without needing to change my whole computer language and make a reboot to configure the second language in a parallel branch)

I think it can be a SUPERUSEFUL integration that a lot of people will strongly appreciate!! :smile: :crossed_fingers:t4:

I think that this is a basic problem that blocks UiPath grow, when I train people in my company, they always get frustrated by language handling and they don’t like the idea that their automation will only work in a single language or that they need to “duplicate” efforst to develop something that can handle other languages…a lot of people stops using UiPath when they see this point.

@Airun
still we recommend to split it off and not mixing up with this thread

You can submit your ideas by using the feedback category

We handle different languguages by within 1 implementation and would react very critical on redundancies only due multi-lang handling

Building factors for this are:

  • dynamic detections of culture details
  • parametrizations
  • Regex Selectors
    and a few more used or combined with

However with feedbacks other approaches could be brought forward e.g. making Object Repository / UiLibrary more flexoble for those scenarios

Yes, I know, I already submitted the idea some weeks ago, I hope they will like and implement it. :smile: :crossed_fingers:t4:

In StudioX we don’t always have acces to the ressources you indicated (for example I tried to detect the computer language but there is no activity for it and using code it don’t works, it always give value “iv”). From my side, I can access Advances Studio as I’m part of IT and I have an advanced developer licence but I always try to automate in StudioX to give more feedback, ideas and examples to the rest of my colleagues who are all using StudioX and having very little knowledges. My ideas are most focused there, on StudioX because they are the ones who are sometimes non-informatic users and who need this kind of helps when they try to create their automations.

as a few times mentioned: we prefer to scope 1 Topic = 1 Case. So other researchers can faster find solutions for their similar problems.

Same for your inputs. So init discussions by new Topics and do not missmatch with this thread. Thanks for support