forEach(fileName: string, callback: (item: Item, i?: number) => void): void
Parameter | Type | Description |
fileName | string | The names of the parameter files that are traversed. |
callback | function | The callback function; item is of Item type, representing a row of data in the parameter file; i is of numeric type, representing the row number of that row of data. |
Type | Description |
void | No content returned. |
import dataset from 'pts/dataset';export function setup() {// Traverse the parameter file named 'test.csv'.dataset.forEach('test.csv', (item) => {// Change the data value of the key 'key5' in the data row item to '555'.item.data.key5 = '555';// If the data value of the key 'key1' in the data row item is '1', mark it as deleted, and it will not be used during the execution of this script.if (item.data.key1 === '1') {item.delete();}});}
import dataset from 'pts/dataset';export function setup() {// Traverse the parameter file named 'test.csv'.dataset.forEach('test.csv', (item, i) => {// Output.// 0: {"name":"1","value":"111"}// 1: {"name":"2","value":"222"}// 2: {"name":"3","value":"333"}console.log(i, ': ', JSON.stringify(item.data));});}
Feedback