Can you save multiple tables in a single csv file?

please format code with </> button * homework policy * asking questions

I am trying to add and save multiples tables in a single CSV file, I have a car class and every car class inherits its own table but when I stop the program and check my CSV file out, only the table of car 3 appears out of 4 cars …Is it because I add the third car later in the program after 20 seconds,
Regards

1 Like

Hi,

You have two options :

  • I assume Car is a class. Then you can declare a static attribute being a Table object holding all the information of you cars.
    Then you can just keep adding columns with addColumn()

  • The second solution is to save a CSV file per instances of the class Car. It means that each instance is going to have a Table class as attribute. In order to save the table with different names for your cars, you can have an id for each instance (saveTable(car_table, "car_" + this.id);)

1 Like

Thanks a bunch, I actually thought of the first way and it works.
Thanks a lot.

2 Likes