Config file for project

Hello Masters,

One question,

For new project, I must create Config file, and with that Config file I must read some Template file like starting point for automation.
image
This template file

What is best practice for that?

Thank you all…I appreciate.

Hi,

  1. Create a config file in project folder.
  2. Use read cell activity to get the value from desired cell range.
    or if you wish to get entire column use read column and use for each loop.

Ok, I am not clear how to that my friend. For now I created this
image

then

This is argument panel

What next? In column Value I have path to do file. What is next step? Can you help?

Anyone ??

Did you reference the Config and InitAllSettings.xaml which you can get by starting a new project using the “Robotic Enterprise Framework”. The InitAllSettings file gives an example on how to return a dictionary back with the settings.

To add (and this is just my preference), I recommend dynamically looping the sheets, so it can be more flexible on what sheets are contained in the spreadsheet rather than hardcoding the sheet names. You can get the sheets with a WorkBook application variable (using the Excel Scope) with wb.GetSheets. -Then, you can remove that argument. However, that depends on your preference I suppose. -The two main problems I have with the InitAllSettings is that it doesn’t use an Excel Read Range (Workbook Read Range requires the file to be closed) and that it requires that you give it the sheet names.

Hi @Gagi77 if the goal is to have these three values accessible at once, a Dictionary pairing might not be best. A better use for a config file with Dictionary type is typically a key value, and a second one associated with it. Your current Dictionary won’t allow you to have a second column value associated with your key value.

For your example here I would use the following:

  1. Read range activity. Pass this into a normal DataTable variable.
  2. Use the “Lookup” activity from the DataTable category. This will allow you to return the values from Column B and C more easily by manipulating the “Target Column” section to get the desired value from either B or C.

check out the xaml file to get you started :wink:

Main.xaml (4.8 KB) project.json (911 Bytes)

I resolved like this



It works great,
thank you all for you patience
Cheers

1 Like

@Gagi77

I noticed you have 3 columns in your config. So are you wanting something that results in something like this:
Config("dept1")("sect1").ToString
where it is a 2 dimensional dictionary and you reference the Name using 2 keys rather than 1? If so, you might need to use a type of Dictionary<of String, dictionary<of String, object>>
This just requires that when you initialize the dictionary, you use something like this: new Dictionary(of String, new Dictionary(of String, object) )
Then, when you assign the value, outConfigFile(row("Department").ToString)(row("Sector").ToString) = row("Name").toString.Trim

and, if you actually have 4 columns, then you need to make it 3 dimensions.
type: Dictionary<of String, dictionary<of String, dictionary<of String, object>>>
assign: outConfig = new Dictionary(of String, new Dictionary(of String, new Dictionary(of String, object) ) )
assign inside loop: outConfigFile(row("Department").ToString)(row("Sector").ToString)(row("Name").ToString) = row("Value").ToString.Trim

or just use a DataTable instead :smiley:

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