Escape characters does not work with CSV parameter

Hi,

I found what seems to be a bug.

If I store a value such as abc\nefg and then echo it, I have :
abc
def

If I store the same value from a CSV file and then echo it, I have : abc\ndef, so escape character does not work.

I tried to tricky it, store the csv value in a variable then in another. I insert the string between quotes in the csv file. I doubled escaped. But I found no solution.

The problem is not only “echo”. But I tried to TYPE a value and when I record and replay it works like a charm and record abc\ndef and enter abc (line feed) def when it plays. I would like to avoid a complex routine look for \n in the string and then use SendKey ou XType for the carriage return…

Here is the code to test (testcsv.csv has the abc\ndef value) :

  {
      "Command": "csvRead",
      "Target": "testcsv",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!stringEscape"
    },
    {
      "Command": "store",
      "Target": "${!COL1}",
      "Value": "test"
    },
    {
      "Command": "echo",
      "Target": "${test}",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "abc\\ndef",
      "Value": "test"
    },
    {
      "Command": "echo",
      "Target": "${test}",
      "Value": ""
    }

The result is :
[echo] abc\ndef
then
[echo] abc
def

Thanks.

Eric

Can you attach your CSV? In my test it works:

image

My test: I create the CSV, too:

{
  "Name": "csv1",
  "CreationDate": "2021-4-19",
  "Commands": [
    {
      "Command": "store",
      "Target": "abc\\ndef",
      "Value": "!csvline"
    },
    {
      "Command": "csvSave",
      "Target": "testcsv",
      "Value": ""
    },
    {
      "Command": "csvRead",
      "Target": "testcsv",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!stringEscape"
    },
    {
      "Command": "store",
      "Target": "${!COL1}",
      "Value": "test"
    },
    {
      "Command": "echo",
      "Target": "${test}",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "abc\\ndef",
      "Value": "test"
    },
    {
      "Command": "echo",
      "Target": "${test}",
      "Value": ""
    }
  ]
}

Hi,

Thanks for you interest !

I don’t create the csv file inside the ui.vision RPA. I use the hard drive location (datasources) where I saved a csv created with notepad++. The testcsv.csv is very simple :
image

And the result is :
image

I managed the problem with Xclick where I replace all \n occurrence, but it would be nice if the solution with TYPE worked.

Thanks for all.

Eric

I confirmed that this is indeed a bug. If the CSV file is read, the abc\ndef string is imported as abc\\ndef (so two \ instead of one). => We will fix this asap.

Workaround: Replace each \\n with \n. You can do this with a regular expression:
var str = ${t1}; return str.replace(/\\n/g,"\n");

This macro works:

{
  "Name": "csv2",
  "CreationDate": "2021-4-20",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision/contact",
      "Value": ""
    },
    {
      "Command": "csvRead",
      "Target": "testcsv",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!stringEscape"
    },
    {
      "Command": "store",
      "Target": "${!COL1}",
      "Value": "t1"
    },
    {
      "Command": "echo",
      "Target": "${t1}",
      "Value": "green"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var str = ${t1}; return str.replace(/\\\\n/g,\"\\n\");",
      "Value": "t1b"
    },
    {
      "Command": "echo",
      "Target": "${t1b}",
      "Value": "blue"
    },
    {
      "Command": "type",
      "Target": "id=Message",
      "Value": "${t1b}"
    }
  ]
}

image

Hi,

Great !

And the replacement code will be compatible with a future fix (do I am right ?) since there will be not \n to replace in the CSV imported cell.

Thanks.

Eric.

Exactly! After the fix the replacement code has simply no work to do :wink:

Development does not think it’s a bug: If you have “abc\ndef” in csv, it’s actually just literally “\n” instead of line break. Check out my csv attached below:

testcsv.zip (177 Bytes)

image

If we change it, it might break other use cases. So we will leave it as it is at the moment, especially since there is a good workaround for your use case.

Test macro:

{
  "Name": "csvlinebreaks",
  "CreationDate": "2021-4-27",
  "Commands": [
    {
      "Command": "csvRead",
      "Target": "testcsv",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${!COL1}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${!COL2}",
      "Value": "",
      "Description": ""
    }
  ]
}

Hi,

Thanks a lot for looking at it.

Indeed I used your workaround and it is only one line to add, and it works fine. We just have to know.

Eric.