0% found this document useful (0 votes)
49 views2 pages

Skript Tulis Done CSV

This script reads data from a CSV file into an array, loops through each row of the array, performs actions on the row depending on the value in the last column, and updates the last column to "done" before saving the array back to the same CSV file. It comments on the current row, skips rows already marked as "done", performs other actions on remaining rows, and updates the CSV to mark the row as processed.

Uploaded by

Rendy Rino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views2 pages

Skript Tulis Done CSV

This script reads data from a CSV file into an array, loops through each row of the array, performs actions on the row depending on the value in the last column, and updates the last column to "done" before saving the array back to the same CSV file. It comments on the current row, skips rows already marked as "done", performs other actions on remaining rows, and updates the CSV to mark the row as processed.

Uploaded by

Rendy Rino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

{

"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": ""
}
]
}

You might also like