- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name | ### loadTable()
Examples |
    // The following short CSV file called "mammals.csv" is parsed
    // in the code below. It must be in the project's "data" folder.
    //
    // id,species,name
    // 0,Capra hircus,Goat
    // 1,Panthera pardus,Leopard
    // 2,Equus zebra,Zebra

    Table table;

    void setup() {

      table = loadTable("mammals.csv", "header");

      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);
      }

    }

    // Sketch prints:
    // 3 total rows in table
    // Goat (Capra hircus) has an ID of 0
    // Leopard (Panthera pardus) has an ID of 1
    // Zebra (Equus zebra) has an ID of 2
Description | Reads the contents of a file or URL and creates an Table object with its values. If a file is specified, it must be located in the sketch's "data" folder. The filename parameter can also be a URL to a file found online. The filename must either end in an extension or an extension must be specified in the options parameter. For example, to use tab-separated data, include "tsv" in the options parameter if the filename or URL does not end in .tsv. Note: If an extension is in both places, the extension in the options is used. If the file contains a header row, include "header" in the options parameter. If the file does not have a header row, then simply omit the "header" option. Some CSV files contain newline (CR or LF) characters inside cells. This is rare, but adding the "newlines" option will handle them properly. (This is not enabled by default because the parsing code is much slower.) When specifying multiple options, separate them with commas, as in: loadTable("data.csv", "header, tsv") All files loaded and saved by the Processing API use UTF-8 encoding.
Syntax |
    loadTable(filename)
    loadTable(filename, options)
Parameters |
filename | String: name of a file in the data folder or a URL.
options | String: may contain "header", "tsv", "csv", or "bin" separated by commas
Returns | Table
Related | Table saveTable() loadBytes() loadStrings() loadXML()

Updated on January 1, 2021 03:38:07am EST
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.