for me looks like spread sheet CSV file
level , layer , time , a,b,c,d,e,f,g,h,
1,1,2.0,1,200,400,1,0,25,2,2
//...
Table table;
String infilename = "data/game.csv";
/*
level , layer , time , a,b,c,d,e,f,g,h
1,1,2.0,1,200,400,1,0,25,2,2
*/
String outfile = "data/newuser.csv";
int trows = 0, tcols;
//____________________________________________________________
void setup() {
size(500, 500);
background(200, 200, 0);
if ( true ) {
get_Table(); //_____________________________________________ IF TABLE EXISTS READ
}
if ( true ) {
make_Table(); //____________________________________________ EXAMPLE TABLE MAKE FILL WRITE
make_Line();
saveTable(table, outfile);
}
}
//____________________________________________________________
void draw() {
// background(200,200,0);
}
//____________________________________________________________
void get_Table() {
table=loadTable(infilename, "header");
trows = table.getRowCount();
tcols = table.getColumnCount();
println("rows: "+trows+" columns: "+tcols+" in file: "+infilename);
table.setColumnType("Level", Table.INT); // optional type setting...
fill(0); //__________________________________________________________________ text color on canvas
int dy =0;
for ( int c = 0; c < tcols; c++) text( table.getColumnTitle(c)+" ", 10+30*c, 10); //___ print header line
dy++;
for ( int r = 0; r < trows; r++) { //________________________________________ get data lines
TableRow thisrow = table.getRow(r);
for ( int c = 0; c < tcols; c++ ) text( thisrow.getString(c), 10+30*c, 10+15*dy );
dy++;
}
}
//_____________________________________________________________________________ options for table create / fill / save
void make_Table() {
table = new Table();
table.addColumn("level");
table.addColumn("layer");
table.addColumn("time");
table.addColumn("a");
table.addColumn("b");
table.addColumn("c");
table.addColumn("d");
table.addColumn("e");
table.addColumn("f");
table.addColumn("g");
table.addColumn("h");
}
void make_Line() {
TableRow newRow = table.addRow();
newRow.setInt("level", 1);
newRow.setInt("layer", 1);
// newRow.setString("time", ""+year()+"_"+nf(month(), 2)+"_"+nf(day(), 2)+"_"+nf(hour(), 2)+"_"+nf(minute(), 2)+"_"+nf(second(), 2));
newRow.setFloat("time", 2.0);
newRow.setInt("a", 1);
newRow.setInt("b", 200);
newRow.setInt("c", 400);
newRow.setInt("d", 1);
newRow.setInt("e", 0);
newRow.setInt("f", 25);
newRow.setInt("g", 2);
newRow.setInt("h", 2);
}
void keyPressed() {
if ( key == 's' ) {
saveTable(table, outfile);
println("save to "+outfile);
}
}