参考 set()

set()

Stores a value in the Table's specified row and column. The row is specified by its ID, while the column may be specified by either its ID or title.

示例

// Given the CSV file "mammals.csv"
// in the project's "assets" folder:
//
// id,species,name
// 0,Capra hircus,Goat
// 1,Panthera pardus,Leopard
// 2,Equus zebra,Zebra

let table;

function preload() {
//my table is comma separated value "csv"
//and has a header specifying the columns labels
table = loadTable('/assets/mammals.csv', 'csv', 'header');
}

function setup() {
table.set(0, 'species', 'Canis Lupus');
table.set(0, 'name', 'Wolf');

//print the results
for (let r = 0; r < table.getRowCount(); r++)
for (let c = 0; c < table.getColumnCount(); c++)
print(table.getString(r, c));

describe('no image displayed');

语法

set(row, column, value)

参数

row
Integer:

row ID

column
String|Integer:

column ID (Number) or title (String)

value
String|Number:

value to assign

Notice any errors or typos? Please let us know. Please feel free to edit src/io/p5.Table.js and open a pull request!

相关参考