Table (vuo.table)
Nodes for working with information that has a tabular structure made up of rows and columns, like a spreadsheet.
You can import a spreadsheet into a Vuo composition by exporting it from your spreadsheet application in CSV (Comma-Separated Values) or TSV (Tab-Separated Values) format and using the Fetch Data and Make Table from Text nodes. You can export CSV or TSV data from a Vuo composition, to be imported into your spreadsheet application, by using the Format Table and Save Data nodes.
Like a spreadsheet, Vuo’s Table data type stores information in a grid of rows and columns. For example, here’s a table of top-ranking tennis players (source: http://www.wtatennis.com/rankings):
Rank | Player | Country | Points |
1 | Serena Williams | United States | 7010 |
2 | Angelique Kerber | Germany | 6925 |
3 | Karolina Pliskova | Czech Republic | 6020 |
4 | Dominika Cibulkova | Slovak Republic | 5065 |
5 | Simona Halep | Romania | 5021 |
This table has 6 rows and 4 columns. In several nodes, such as Get Table Row and Get Table Column, you can refer to rows and columns by number, counting left-to-right or top-to-bottom starting from 1. For example, the header row of this table is row 1, and the bottom row (Simona Halep) is row 6.
You can also refer to rows and columns by header if there is one. The table above has headers for the columns (but not for the rows). With the Get Table Column node, you could request the row with header Player to get a list of all of the players' names.
To switch between these two modes of referring to rows/columns — numbers or headers — change the data type of the Row/Column port. (Right-click on the port and select Integer or Text from the Set Data Type submenu.)
Vuo stores each item of the table as text (even if it’s a number or date). With the Sort Table node, you have the option to treat the sorted column as a number or date, instead of sorting it alphabetically like text. When you retrieve table items with the Get Table Row, Get Table Column, or Get Table Item node, the items are output as text. You can convert them to numbers using nodes such as Convert Text to Integer and Convert Text List to Real List.
Example compositions:
- Change Table Data to Metric: Changes temperature data in a table from Fahrenheit to Celsius, and saves the modified table to a CSV file.
This composition does not display a window.
Data source: Coldest recorded temperature on each continent from https://en.wikipedia.org/wiki/List_of_weather_records
- Display Pet Adoptions Table: Downloads a CSV file and displays its data in a grid.
Data source: Pet adoptions in King County, Washington, USA in 2016 from https://catalog.data.gov/
- Graph Coldest Temperatures: Draws a graph of temperatures (in Celsius) by location, ordered from warmest to coldest.
Data source: Coldest recorded temperature on each continent from https://en.wikipedia.org/wiki/List_of_weather_records
- Perform Coin Flip Experiment: Simulates a series of coin flips and saves the results to a CSV file. In each of 15 trials, a coin is flipped 10 times, and the number of times it came up heads is recorded.
This composition does not display a window.
- Record Mouse Clicks to CSV File: Records the location of each double-click and, when the Save button is pressed, saves them to a CSV-formatted file (similar to the Record and Play Values node).
Nodes:
- Add Table Column (vuo.table.add.column): Inserts a column in a table, either before the first column or after the last column.
- Add Table Row (vuo.table.add.row): Inserts a row in a table, either before the first row or after the last row.
- Change Table Column (vuo.table.change.column): Replaces the values in one column of a table.
- Change Table Item (vuo.table.change.item): Replaces an item in a table.
- Change Table Row (vuo.table.change.row): Replaces the values in one row of a table.
- Fetch Table (vuo.table.fetch): Loads or downloads a file containing CSV- or TSV-formatted text, and turns the text into a table.
- Find Table Row (vuo.table.find): Finds the first matching item in a table, and outputs the entire table row containing that value.
- Format Table (vuo.table.format): Turns a table into CSV- or TSV-formatted text.
- Get Table Column (vuo.table.get.column): Outputs the values in one column of a table.
- Get Table Item (vuo.table.get.item): Outputs one item in a table.
- Get Table Row (vuo.table.get.row): Outputs the values in one row of a table.
- Make Table from Text (vuo.table.make.text): Turns CSV- or TSV-formatted text into a table.
- Sort Table (vuo.table.sort): Sorts a table’s rows by the values in the chosen column.
- Take Column from Table (vuo.table.take.column): Removes either the first or last column from a table.
- Take Row from Table (vuo.table.take.row): Removes either the first or last row from a table.
- Transpose Table (vuo.table.transpose): Diagonally flips a table, turning rows into columns and columns into rows.