Read Text File output string contains "@" character

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:

  1. Use Read CSV and and do all get/set operations on the config file using data table activites, or
  2. 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?

  1. Why is UIPath putting an @ symbol into the Read Text File output string?
  2. 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.

-Tom

1 Like

The @ character is indicating that the string is not escaped etc and it is not part of the string

1 Like

@ppr - I appreciate but do not understand your response.

  1. I’m not sure what you mean by “the string is not escaped”.
  2. 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.

-Tom

1 Like

for example we do have following text file (1 of many ways to test/replicate)
grafik

And we do read in the text file into a string:
grafik

we get:
grafik

But the @ is not part of the string content, as you can see below:
grafik

Please read this:
Verbatim strings in C# - Use of @ symbol in string literals (c-sharpcorner.com)

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.

Stick to what works :slight_smile:

@ppr and @Jeroen - thank you for taking the time to respond.

  1. Change the value of environment to “production”.
  2. Use the Matches activity and the Text To Left/Right activities to find and parse the line “environment,production”.

image

  1. Set up a couple of if statements:

The “if contains” is successful. The “if equals” fails. There are no extraneous spaces anywhere that I can find.

-Tom

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

it is not really clear what you want to show/replicate. Maybe you can do it more simple within the immediate panel.

About the following, maybe you can show us the screenshots along with the configured properties of your implementation: