Hello, here is a sample loop that you can actually always use.
I have taken it from a working script, you have to adapt the CSV.
In addition, everything from the CSV is packed into an array and at the end every line is deleted from the array and therefore also from the CSV file.
This way, if a loop breaks off, you don’t always have to delete everything manually from the CSV.
{
"Command": "csvRead",
"Target": "1.mydata.csv",
"Value": "",
"Description": ""
},
{
"Command": "csvReadArray",
"Target": "1.mydata.csv",
"Value": "meinArray",
"Description": ""
},
{
"Command": "store",
"Target": "${!CsvReadMaxRow}",
"Value": "maxRows",
"Description": "Anzahl der Zeilen speichern"
},
{
"Command": "echo",
"Target": "Anzahl Zeilen der CSV: ${maxRows}",
"Value": "",
"Description": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "return parseInt(${!csvReadLineNumber}) + 1",
"Value": "!csvReadLineNumber",
"Description": "Increase here the numer in Target in which row the loop should startet. If the loop should start at Row 2 = +1 | If loop start in Row 3 = +2 and so on"
},
{
"Command": "comment",
"Target": "------------------ LOOP STARTS ---------------",
"Value": "",
"Description": ""
},
{
"Command": "label",
"Target": "startLoop",
"Value": "",
"Description": ""
},
{
"Command": "csvRead",
"Target": "1.mydata.csv",
"Value": "",
"Description": ""
},
{
"Command": "csvReadArray",
"Target": "1.mydata.csv",
"Value": "meinArray",
"Description": ""
},
{
"Command": "while",
"Target": "${!csvReadLineNumber} <= ${maxRows}",
"Value": "",
"Description": "loop to the last and empty row CSV"
},
{
"Command": "executeScript_Sandbox",
"Target": "return parseInt(${!csvReadLineNumber})",
"Value": "!csvReadLineNumber",
"Description": "Increace Value + 1 for the next row"
},
{
"Command": "comment",
"Target": "########### WRITE ONLY HERE YOUR OWN COMMANS",
"Value": "",
"Description": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "var meinArray = ${meinArray}; meinArray.splice(1, 1); return meinArray;",
"Value": "meinArray",
"Description": ""
},
{
"Command": "csvSaveArray",
"Target": "meinArray",
"Value": "1.mydata.csv",
"Description": ""
},
{
"Command": "echo",
"Target": "Row finished",
"Value": "",
"Description": ""
},
{
"Command": "gotoLabel",
"Target": "startLoop",
"Value": "",
"Description": "jump to next row in csv"
},
{
"Command": "comment",
"Target": "----- END WHILE LOOP -----",
"Value": "",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
}