CSV file into Processing with Table

edited April 2016 in Questions about Code

Hi, I'm new to Processing and struggling with getting my table to recognise the rows in the CSV file. The error message keeps reading "this table has no column named "name"". Please help and tell me what I'm doing wrong. :(

https://data.nasa.gov/view/ak9y-cwf9 (data table here)

Screen Shot 2016-04-12 at 14.25.09 Screen Shot 2016-04-12 at 12.00.44

Answers

  • edited April 2016

    There is an error in the CSV file format. It is likely a non standard file header or something like that.
    Open it in Open Calc etc, then resave it. Your code works fine after that for me.

    edit:
    Downloaded file size: 5,022,814 bytes
    Save As file size: 4,769,383 bytes
    Well that is the weirdest thing I've ever seen.
    Anyone know what's up with this CSV file?

    BTW!!!! Don't println() 45,716 lines to the console, it only has something like 500 lines of memory. The console will crash without a doubt.

    Interestingly, you can access the other columns just fine.

    Table table;
    void setup() {
      table = loadTable("data/Meteorite_Landings.csv", "header, csv");
      println(table.getRowCount() + " rows.");
      TableRow row = table.getRow(45715);
      print("ID: " + row.getString("id") + " ");
      println(row.getString("year"));
    }
    

    Prints:

    45716 rows.
    ID: 30414 01/01/1976 12:00:00 AM
    



    SaveAs data:

    Table table;
    void setup() {
      table = loadTable("data/Meteorite_LandingsSAVEAS.csv", "header, csv");
      println(table.getRowCount() + " rows.");
      TableRow row = table.getRow(45715);
      print(row.getString("name"));
      print(", ID: " + row.getString("id") + " ");
      println(row.getString("year"));
    }
    

    Prints:

        45716 rows.
        Zulu Queen, ID: 30414 01/01/1976 12:00:00 AM
    
  • edited April 2016

    Double post after editing.

Sign In or Register to comment.