Using a csv file with ui vision : update, clear, or get last value

Hello,

I have to save data from a form since a macro, and re-use this data into another macro.
So I use the csvSave command from ui.vision, and csvRead too.

But, the csvSave command can just add some data one after the other, one per line, each time I launch the macro.
Or I wish to save just one data, into the first line only. I have seen that it is not possible to clear the data into the csv file with ui.vision, and I don’t know how to delete the file with ui.vision (or with javascript) once I don’t need it.

I create the file with a specific name because I have to re-use it into another macro after that.

So, if it is not possible to clear data or delete file before update or create it, or if it is not possible to update or overwrite the first value, how can I get the last value from my csv file ?

For example, my csv file is like this (on line 1 and col A) :
1234
4353
4577
4768
4834

→ I want to get the last value “4834” only.

My ui.vision code for now :

{
“Command”: “storeValue”,
“Target”: “id=numeroSinistre”,
“Value”: “!csvLine”
},
{
“Command”: “csvSave”,
“Target”: “saveClaim.csv”,
“Value”: “”
},
{
“Command”: “csvReadArray”,
“Target”: “saveClaim.csv”,
“Value”: “myCSV”
},
{
“Command”: “echo”,
“Target”: “${myCSV[6][0]}”,
“Value”: “”
}

Thanks in advanced

I do not suggest to use csvReadArray bacause it’s statt from 0 and create confusion, in your code you used 6 but 6 is 7 line non 5 line

    {
    “Command”: “echo”,
    “Target”: “${myCSV[6][0]}”,
    “Value”: “”
    }

You can only create a new csv and save date in new csv

No option to edit existing csv, you can add line only.

To do this you need external software like powershell

TO solve your problem you need a simple command

store ${!csvReadMaxRow} !csvReadLineNumber

With this you set the last line in csv like current line to read and now with ${!COL1} you have the value of your last line in csv

1 Like

Thank you for your answer,

I tried the csvReadMaxRow command, but it seems not supported…

Here my code :

{
“Command”: “storeValue”,
“Target”: “id=numeroSinistre”,
“Value”: “!csvLine”
},
{
“Command”: “csvSave”,
“Target”: “saveClaim.csv”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “${!csvReadMaxRow}”,
“Value”: “!csvReadLineNumber”
},
{
“Command”: “csvRead”,
“Target”: “saveClaim.csv”,
“Value”: “”
},
{
“Command”: “echo”,
“Target”: “${!COL1}”,
“Value”: “”
}

Here the error displayed :
Internal variable “!CSVREADMAXROW” not supported

EDIT :

I just add a csvRead command before the store !csvReadMaxRow, and it’s working ! :slight_smile:

1 Like

For information on how to update or overwrite a value in a CSV file see How to mark a row in a CSV line as processed? - #3 by TechSupport

1 Like