I am using a csv file to hold global variables and constants for an automation project. I know it’s common to use the 3 worksheet config.xlxs (see: How to use a Config file in UiPath - Tutorial - YouTube), but I think it’s easier to use a csv.
My config file is named config.txt and looks like this:
yada,yadayada
blah,blahblah
environment,test
I’ve been running some tests:
Use Read CSV and and do all get/set operations on the config file using data table activites, or
Use Read Text File and do all get/set operations on the config file using string handling activities.
Right now I’m testing option #2. Using string handling I can find and return existing values in the config file. There is currently 1 snag. When I use Read Text File to get the config file into a UIPath string, it looks like this:
This is not a huge problem since I can test the config file string with string.contains(“something”) instead of string = “something”, but could someone please answer 2 questions?
Why is UIPath putting an @ symbol into the Read Text File output string?
If you look at the first line of the file you can see a squiggle under the ‘y’ of ‘yadayada’. When you mouse hover over the squiggle there’s a popup that says “End of statement expected.”
I thank you, Mesdames et Messieurs, for your kindly informification.
@ppr - I appreciate but do not understand your response.
I’m not sure what you mean by “the string is not escaped”.
As to whether the @ symbol is part of the string: when I use write line on the string, the @ symbol does not get written to the console. When I parse the environment line using Text to Left/Right,
Text to left = “environment”
Text to right sometimes = “test” and sometimes = @test"
When I run a string test on the Text to Right string.contains(“test”) succeeds but string = “test” fails.
It is basically an indicator used to treat the string litterally, and not interprid potential escape characters such as the /. So the @ character is not part of your string, therefor it is not displayed when using writeline.
As for your usage of a txt file for storing these type of name/value pairs… I can understand the appeal of staying away from an excel config, and it surely can have its advantages in certain cases, but I’d definately go for the read csv activity. Using a for each row on the content makes it so much easier to create a config dictionary over reading an entire tex file and using string manipulation to try and get the same end result.
Whoops. I just realized that I forgot to return the 2nd if statement to use
tmpStrR.ToString.ToUpper.Equals(“PRODUCTION”)
but I’ve changed it and the “equals” still fails.
Also, @Jeroen - I partly abondoned the Read CSV / Data Table approach. It was so frustrating that you must use the Lookup Data Table to find a matched RowIndex, but Lookup Data Table does not return a row object, which activities like Update Row Item require as an input! It is so frustrating that there does not seem to be an easy way to convert a row index to a row object. I’m sure you can do this in VB/Invoke code, but I am not able to get Invoke Code to ever work. (See: Invoke Code Always Fails: Method Not Found - Help / Activities - UiPath Community Forum