The classic csvSave command is only for the standard case, which is to create a new line for each entry. But with csvSaveArray you have full control over the CSV file. This macro does what you want:
- First we create an array
- Then we start a times loop:
– Then we set a certain cell to the value in line 7.
– Then save the array to CSV - same line for every loop!
See also How to mark a row in a CSV line as processed? - #3 by TechSupport which uses csvSaveArray, too.
{
"Name": "Save2SameRow",
"CreationDate": "2021-3-22",
"Commands": [
{
"Command": "comment",
"Target": "Read CSV file to array",
"Value": ""
},
{
"Command": "store",
"Target": "fast",
"Value": "!replayspeed"
},
{
"Command": "comment",
"Target": "Create an array. Later we save the content to a CSV file",
"Value": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "var arr = []; for(var row = 0; row < 5; row++){arr[row] = []; for(var col = 0; col < 3; col++){arr[row][col] = \"\";}}; return arr",
"Value": "array1"
},
{
"Command": "times",
"Target": "3",
"Value": ""
},
{
"Command": "comment",
"Target": "Always write in 2nd line (index=1)",
"Value": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "var newArr = ${array1}; newArr[1][0] = \"t=\"+${!times}; return newArr",
"Value": "array1"
},
{
"Command": "csvSaveArray",
"Target": "array1",
"Value": "test1.csv"
},
{
"Command": "end",
"Target": "",
"Value": ""
}
]
}