Where to put csv files in Processing 3?

Hello I am new to Processing. I want to parse a csv file but it does not get it.
Can you help me please?
Thanks
My code is :slight_smile:

Table table;

void setup() {
  
  table = loadTable("C:/Users/Seyfi/Desktop/processing-3.5.3/mammals.csv", "header, csv");

  println(table.getRowCount() + " total rows in table"); 

  for (TableRow row : table.rows()) {
    
    int id = row.getInt("id");
    String species = row.getString("species");
    String name = row.getString("name");
    
    println(name + " (" + species + ") has an ID of " + id);
  }
  
}
1 Like

C:/Users/Seyfi/Desktop/processing-3.5.3/mammals.csv does not exist or could not be read
NullPointerException

This is the error I get

the processing way is to make under the sketch dir
a subdir /data/ where you have files like

  • fonts
  • image
  • data
  • saved image/ pdf/ files( string / csv / json ) …
    so please start with
String infile = "data/mammals.csv", outfile = "data/backup.csv";
table = loadTable(infile, "header, csv");

only this way you keep your data with the project and are mostly independent from OS the project is run from later.


also the install directory
processing-3.5.3
is a bad place for user data.

possibly you have a other problem,
where is your sketch directory?
/ File / Preferences /
Sketchbook location:
???

1 Like

C:\Users\Seyfi\Desktop\processing-3.5.3\modes\java\application

This is where the sketch file is under. Is it fine?

no, i would call that a system directory
for the Processing 3.5.3

and also that that is under Desktop ( not totally bad, ) shows that you might not know how to handle disk and files under windows?

again, did you set that sketch path in the preferences?

Processing IDE / File / Preferences / Sketchbook location:

a windows way would be

C:\Users\Seyfi\Documents\projects\processing\

( make the dirs projects\processing\ first )

later when you use

Processing IDE / File / Sketchbook

that directory opens and show your sketches
my_sketch_1 ( click for open )
( contains: my_sketch_1/mysketch_1.pde )

1 Like

I dont know how to set sketch path, any reference can you recommend me?
I created a c:\Users\Seyfi\Documents\projects\processing\ folder\first , but dont know the rest .
Thanks

that is menu operation
[File]
…[Preferences]

1 Like

Thank you so much for your help ad time :slight_smile:

image
Where should I put my csv file here?
Thanks

no, first save your code using
/ File / Save As /
so we can see that project in above directory

I really thank you :slight_smile:

/TableS contains TableS.pde ?

down there you create /data/

/TableS/data/

and copy csv file into

/TableS/data/mammal.csv


and not forget to declare

String infile = "data/mammals.csv";
1 Like

Thanks :slight_smile: I really appreciate your help

4 posts were split to a new topic: Csv does not exist or could not be read NullPointerException