Read and Parse a CSV File in Larzscript
Parse CSV text into rows, or straight into dicts keyed by header - including quoted fields with embedded commas.
csv.parse_dicts() keys every row by its header instead of by index, and raises a clear error the moment a row's field count doesn't match, instead of silently misaligning data three columns later.
larzscript pkg install csv
Code
import "csv" as csv let text = "name,age,city\nAda,36,London\nBo,24,\"Paris, France\"" let people = csv.parse_dicts(text) print(people[0]["name"], people[0]["age"]) print(people[1]["city"])
Output
Ada 36 Paris, France
Related
larzcsvRFC-ish CSV parse/write→Parse JSON in LarzscriptParse a JSON string into real Larzscript dicts and lists, and turn data back into JSON text.→Encode and Decode Base64 in LarzscriptBase64-encode arbitrary text (or decode it back), the standard way binary-ish data travels safely through text-only channels like JSON or URLs.→Parse a URL in LarzscriptBreak a URL into its scheme, host, path and query parameters, and safely join a base URL with a relative path.→