csvlib Reference
Module defined in `lua/common/csvlib.lua`. Provides CSV and TSV creation, writing, and RFC 4180-compliant parsing.
Module defined in lua/common/csvlib.lua. Provides CSV and TSV creation, writing, and RFC 4180-compliant parsing.
Exports
Functions
M.newCSV(...)
Creates a new CSV writer with optional column headers.
- Parameters:
...- string - Column header names
- Returns: csvWriter - A CSV writer object with comma delimiter
M.newTSV(...)
Creates a new TSV writer with optional column headers.
- Parameters:
...- string - Column header names
- Returns: csvWriter - A TSV writer object with tab delimiter
M.decode(s, sep)
Parses a CSV/TSV string into a 2D table. Handles quoted fields, embedded delimiters, and numeric auto-detection.
- Parameters:
s- string|nil - CSV content to parsesep- string|nil - Single-character delimiter (default: comma)
- Returns:
table- Parsed result
M.readFileCSV(filename, sep)
Reads and parses a CSV file from disk.
- Parameters:
filename- string - Path to CSV filesep- string|nil - Delimiter character
- Returns:
self(module table, for chaining)
csvWriter Methods
writer:add(...)
Appends a row of values. Handles string quoting, number formatting (%.10g), boolean conversion (1/0).
- Parameters:
...- any - Values for each column
- Returns: csvWriter - Self (for chaining)
writer:dump()
Returns the accumulated CSV content as a string.
- Returns: string - Full CSV content
writer:write(filename)
Writes the CSV to a file. Auto-appends datetime suffix if no extension present.
- Parameters:
filename- string|nil - Output filename (defaults to header abbreviation or "csv")
- Returns: string - Actual filename written
Internal Notes
- Uses
string.bufferfor efficient concatenation - The decoder handles: quoted strings with escaped quotes, numeric auto-detection, trailing empty row cleanup
- Writer properly escapes fields containing delimiters, quotes, CR, or LF
controlSystems Reference
Module defined in `lua/common/controlSystems.lua`. Provides PID controller implementations in both parallel and standard forms, commonly used for vehicle systems like cruise control, steering assist,
delayLine Reference
Module defined in `lua/common/delayLine.lua`. Implements a time-based delay buffer for queuing data packets that arrive at one end and exit after a fixed time delay. Originally designed for simulating