Read CSV File more than one time in a loop

I used the DemoReadCSVwithWhile file to make a test. I added a LABEL on top, and a GotoLabel at the end => it loops forever.

However, once the variable !csvReadStatus is equal to “end_of_file” and it is read-only a can’t start reading the file again.

What error message do you get? As mentioned above, re-reading the same file again works fine in my test.

Log file says:

Reading CSV line No. 3
[echo]
status = OK, line = 3
[echo]
Reading CSV line No. 4
[error][ignored]
end of csv file reached
[echo]
— Read CSV Test starts here —
[echo]
Status = OK, line = 1 <== works fine again
[echo]
status = OK, line = 1
[echo]
Reading CSV line No. 2

Test macro (you can copy and paste it to the Source tab for testing):

{
  "CreationDate": "2018-5-25",
  "Commands": [
    {
      "Command": "label",
      "Target": "xxxxx",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "180",
      "Value": "!timeout_macro"
    },
    {
      "Command": "store",
      "Target": "fast",
      "Value": "!replayspeed"
    },
    {
      "Command": "echo",
      "Target": "--- Read CSV Test starts here ---",
      "Value": ""
    },
    {
      "Command": "label",
      "Target": "TESTSTART",
      "Value": ""
    },
    {
      "Command": "csvRead",
      "Target": "ReadCSVTestData.csv",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Status = ${!csvReadStatus}, line = ${!csvReadLineNumber}",
      "Value": ""
    },
    {
      "Command": "while",
      "Target": "\"${!csvReadStatus}\" == \"OK\"",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "status = ${!csvReadStatus}, line = ${!csvReadLineNumber}",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "https://docs.google.com/forms/d/e/1FAIpQLScGWVjexH2FNzJqPACzuzBLlTWMJHgLUHjxehtU-2cJxtu6VQ/viewform",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=entry.933434489",
      "Value": "${!COL1}_${!csvReadLineNumber}"
    },
    {
      "Command": "type",
      "Target": "name=entry.2004105717",
      "Value": "${!COL2}"
    },
    {
      "Command": "type",
      "Target": "name=entry.1382578664",
      "Value": "${!COL3}"
    },
    {
      "Command": "clickAndWait",
      "Target": "//*[@id=\"mG61Hd\"]/div/div[2]/div[3]/div[1]/div/div/content/span",
      "Value": ""
    },
    {
      "Command": "storeEval",
      "Target": "${!csvReadLineNumber}+1",
      "Value": "!csvReadLineNumber"
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!errorIgnore"
    },
    {
      "Command": "echo",
      "Target": "Reading CSV line No.  ${!csvReadLineNumber} ",
      "Value": "!errorIgnore"
    },
    {
      "Command": "csvRead",
      "Target": "ReadCSVTestData.csv",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "false",
      "Value": "!errorIgnore"
    },
    {
      "Command": "endWhile",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "gotoLabel",
      "Target": "xxxxx",
      "Value": ""
    }
  ]
}
1 Like