Savetable with P5

I’ve got a strange error when trying to save a p5.table

tablo= new p5.table;

I’ve got the following msg:
Exception has occured
Error: creaheader is not defined

but if I enter ‘html’ instead of ‘csv’ everything is working file and the table is save in the file !!

Pls help !

so possibly empty files are not allowed?
need minimum a table structure to make a header line

but usually start the other way, from reading a file
-a- create in online editor a subdirectory
-b- create inthere a new file ‘Memory.csv’
edit it manually with 2 lines minimum,
one header line
one data line

(or upload the file from you computer )

and in your code just use

function preload() {
  table = loadTable('assets/Memory.csv', 'csv', 'header');


I used this example:

I edited it:

let table;

 function setup() {
 table = new p5.Table();

// table.addColumn('id');

 //let newRow = table.addRow();
// newRow.setNum('id', table.getRowCount() - 1);
 //newRow.setString('species', 'Panthera leo');
// newRow.setString('name', 'Lion');

 // To save, un-comment next line then click 'run'
  saveTable(table, 'new.csv');

 // Saves the following to a file called 'new.csv':
 // id,species,name
 // 0,Panthera leo,Lion

It saves a csv file.

This works as well:

 saveTable(table, 'new', 'csv');

Google Chrome was used along with

1 Like

My table is not empty I am entering valus as follows ::

tablo = new p5.Table();



 newRow = tablo.addRow();

newRow.setString('search_key', key_search + "\t");

newRow.setNum('counter', counter);

The strange thing is when I saved the table using :

saveTable(tablo,‘Memory’,‘csv’); I’ve got the error msg

but if I save with:


the save is saved perfectly !

This strange behaviour is the reason of this post

so, you see that you got 2 answers what all say:

saveTable(table, 'filename.csv', 'csv');


saveTable(table, 'filename.csv');

using the online editor,
( i give you already the link to my test code)
but again minimal test what works:

let table = new p5.Table();

function setup() {

and in my case using win 10 / firefox browser

why you not just give us the link to your
project in the online editor so we can reproduce that error.

1 Like

I finally found the error : the p5.js library file was corrupted !
Now everything is working fine

Thanks to all of you

1 Like

I posted these examples along with this reference:

saveTable(table, 'new.csv');

saveTable(table, 'new', 'csv');

Will save a table as:
And adding this:
saveTable(table, 'new.csv', 'csv');

So there are 3 ways to save the table to:


1 Like