saveTable doesn't work with loadTable

Hi,I have been trying to add a new row to a loaded table(new.csv) and save. However, the saved(replaced) .csv file does not show proper data but this strange symbols as below. �w^~)�.

//this is what new.csv looks like.
//id, species
//1, a
//2, b
//3, c
//4, d
//5, e <----- this row is what I want to add

and here is my code:


var table;
function preload() { 
  table = loadTable("new.csv", "csv", "header");
}
function setup() {
  var newRow = table.addRow();
  newRow.setString("id", 5);
  newRow.setString("species", "e");
  for (var r = 0; r < table.getRowCount(); r++) {
    for (var c = 0; c < table.getColumnCount(); c++) {
      println(table.getString(r, c));
    }
  }
  saveTable(table, 'new.csv');
}

The row is properly added when I println(table.getString(r, c)); but not in replaced new.csv file. I tried to save it with different file name as new1.csv but still doesn't work. Could you fix this problem for me? Thank you.

Answers

Sign In or Register to comment.