TYPE random from CSV

Hello world,
I am pretty new here, I am trying to match 2 functions pretty simple but… not working :\

I have the values of the variables ZIPPO, JENGA and OCB (random words) in three columns (A, B, C) in a CSV, stored in the folder C:\temp\

(in case I can switch to three files like zippo.csv and/or txt with no problems)

In the end, the macro should type it in a textbox.

Can someone more experienced support me? I am feeling quite lost and I dunno if is because of my sys or my brain or my poor experience: I am trying with Firefox, Nightly, Chrome… but the same (zero) results ^_^"

Thanks a lot in advance! :slight_smile:

There are a large amount of ways to do this

A fast solution is csvReadArray and use a random choice (executescript)

https://ui.vision/rpa/docs/selenium-ide/csvread

But there are more and more solution to do this

Unfortunately, I have received an error:

Line 1: csv file ‘c:/temp/names.csv’ does not exist. Full path works only in hard-drive mode.

Csv must be in datasouces folder and can not moved in another path

all csv must be saved in datasouces folder

Nada, tried and is still not working :sob:

Read docs create macro require time and study

https://ui.vision/rpa/docs

Capt. Obvious, I already read the docs and I am stuck in a silly point that I cannot see :slight_smile:

Actually I am hoping that post enlightened your day thinking you made the difference in this discussion!

Hi, did you change Storage Mode to File System (on hard drive)? In UI.Vision, bottom left is Storage Mode…

Post csv with data and your macro code and i fix this

Probably i must edit your csv to adapt it a random choice

Post csv and macro code please

I create a good macro code for you

Remember the only way to create automation is study. study and study or pay a professional coder.

It’s a excellent way to have unlimited random extraction from csv.

Csv:

MESSAGE 1,MESSAGE 2,MESSAGE 3,MESSAGE 4,MESSAGE 5,MESSAGE 6,MESSAGE 7,MESSAGE 8,MESSAGE 9,MESSAGE 10

Macro code:

{
  "Name": "Random_Csv",
  "CreationDate": "2020-10-26",
  "Commands": [
    {
      "Command": "times",
      "Target": "10",
      "Value": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber;",
      "Value": "Row"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber;",
      "Value": "Column"
    },
    {
      "Command": "csvReadArray",
      "Target": "test.csv",
      "Value": "MyCsv"
    },
    {
      "Command": "echo",
      "Target": "Loop Number: ${!TIMES}\\n\\n Row Number: ${Row}\\n\\n Column Number: ${Column}\\n\\n Random Message From Csv: ${MyCsv[${Row}][${Column}]}",
      "Value": "#shownotification"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }
  ]
}

Log

[status]

Playing macro Random_Csv

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 1

Row Number: 0

Column Number: 7

Random Message From Csv: MESSAGE 8

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 2

Row Number: 0

Column Number: 1

Random Message From Csv: MESSAGE 2

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 3

Row Number: 0

Column Number: 5

Random Message From Csv: MESSAGE 6

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 4

Row Number: 0

Column Number: 5

Random Message From Csv: MESSAGE 6

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 5

Row Number: 0

Column Number: 4

Random Message From Csv: MESSAGE 5

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 6

Row Number: 0

Column Number: 0

Random Message From Csv: MESSAGE 1

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 7

Row Number: 0

Column Number: 6

Random Message From Csv: MESSAGE 7

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 8

Row Number: 0

Column Number: 1

Random Message From Csv: MESSAGE 2

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 9

Row Number: 0

Column Number: 8

Random Message From Csv: MESSAGE 9

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 0; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Row |

[info]

Executing: | executeScript_Sandbox | var min = 0; var max = 9; var randomNumber = Math.floor(Math.random() * (max - min)) + min; return randomNumber; | Column |

[info]

Executing: | csvReadArray | test.csv | MyCsv |

[info]

Executing: | echo | Loop Number: {!TIMES}\n\n Row Number: {Row}\n\n Column Number: {Column}\n\n Random Message From Csv: {MyCsv[{Row}][{Column}]} | #shownotification |

[echo]

Loop Number: 10

Row Number: 0

Column Number: 3

Random Message From Csv: MESSAGE 4

[info]

Executing: | end | | |

[info]

Executing: | times | 10 | |

[info]

Macro completed (Runtime 20.51s)

1 Like