Table.from_csv()

Read a table from a CSV file. All values are read as strings.

Usage

Source

Table.from_csv(path)

Parameters

path: str | Path
The file to read.

Returns

Table
The table read from the file.

Examples

Save a table with Table.to_csv(), then read it back. CSV files don’t record types, so every value comes back as a string:

import tempfile
from pathlib import Path

from tinytab import Table

path = Path(tempfile.mkdtemp()) / "menu.csv"
Table({"item": ["coffee", "bagel"], "price": [3.5, 2.25]}).to_csv(path)

Table.from_csv(path)
itemprice
coffee3.5
bagel2.25