Skript Tulis Done CSV
Skript Tulis Done CSV
"Name": "DemoMarkCSVasDone",
"CreationDate": "2021-3-8",
"Commands": [
{
"Command": "comment",
"Target": "Read CSV file to array",
"Value": ""
},
{
"Command": "csvReadArray",
"Target": "readcsvtestdata.csv",
"Value": "arr"
},
{
"Command": "echo",
"Target": "Number of rows = ${!CsvReadMaxRow}",
"Value": "green"
},
{
"Command": "executeScript_Sandbox",
"Target": "return ${arr[0]}.length;",
"Value": "col"
},
{
"Command": "echo",
"Target": "Number of columns = ${col}",
"Value": "pink"
},
{
"Command": "comment",
"Target": "loop over all CSV values",
"Value": ""
},
{
"Command": "times",
"Target": "${!CsvReadMaxRow}",
"Value": ""
},
{
"Command": "comment",
"Target": "i -1 because arrays start with index=0",
"Value": "arr"
},
{
"Command": "executeScript_Sandbox",
"Target": "return ${!times} - 1;",
"Value": "i"
},
{
"Command": "echo",
"Target": "Current CSV Row: col1=${arr[${i}][0]}, col2=${arr[${i}][1]},
col3=${arr[${i}][2]}",
"Value": "brown"
},
{
"Command": "if_v2",
"Target": "${arr[${i}][2]} == \"done\"",
"Value": ""
},
{
"Command": "echo",
"Target": "Row ${!times} is already done, skipping it.",
"Value": "green"
},
{
"Command": "else",
"Target": "",
"Value": ""
},
{
"Command": "echo",
"Target": "Row ${!times} -- Form filling etc would be here",
"Value": "blue"
},
{
"Command": "comment",
"Target": "Change last column to DONE <== HERE IS WHERE THE MAGIC HAPPENS",
"Value": "arr"
},
{
"Command": "executeScript_Sandbox",
"Target": "var b = ${arr}; b[${i}][2] = \"done\"; return b; ",
"Value": "arr"
},
{
"Command": "comment",
"Target": "Save array after each loop, use same CSV name",
"Value": "arr"
},
{
"Command": "csvSaveArray",
"Target": "arr",
"Value": "readcsvtestdata.csv"
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
}
]
}