load(path [, sep])
Loads a relation from a CSV file. It expects the file to have a header row.
Pass sep to specify the field separator, e.g. "\t" (the default is ",").
Note: the file should be well-formed: the header row should have a unique name per column, each column name should be a valid Ra attribute name, each row should have the same number of columns, and each column should have a consistent type. Any duplicate rows will be lost in the transformation.
Ra will make efforts to construct valid attribute names and to detect the types from the data in the file, however if it fails, consider first passing the file through a system with a more flexible CSV importer such as SQLite and re-export it as CSV from there.
Examples
load, filter and project
$ head northwind-csv-sample-data/products.csv
ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued 1,Chai,1,1,10 boxes x 20 bags,18.00,39,0,10,0 2,Chang,1,1,24 - 12 oz bottles,19.00,17,40,25,0 3,Aniseed Syrup,1,2,12 - 550 ml bottles,10.00,13,70,25,0 4,Chef Anton's Cajun Seasoning,2,2,48 - 6 oz jars,22.00,53,0,0,0 5,Chef Anton's Gumbo Mix,2,2,36 boxes,21.35,0,0,0,1 6,Grandma's Boysenberry Spread,3,2,12 - 8 oz jars,25.00,120,0,25,0 7,Uncle Bob's Organic Dried Pears,3,7,12 - 1 lb pkgs.,30.00,15,0,10,0 8,Northwoods Cranberry Sauce,3,2,12 - 12 oz jars,40.00,6,0,0,0 9,Mishi Kobe Niku,4,6,18 - 500 g pkgs.,97.00,29,0,0,1
load("northwind-csv-sample-data/products.csv")[Discontinued=1]{ProductID, ProductName, UnitPrice}
┌───────────┬───────────────────────────────┬───────────┐ │ ProductID │ ProductName │ UnitPrice │ ├───────────┼───────────────────────────────┼───────────┤ │ 5 │ Chef Anton's Gumbo Mix │ 21.35 │ │ 9 │ Mishi Kobe Niku │ 97.00 │ │ 17 │ Alice Mutton │ 39.00 │ │ 24 │ Guaraná Fantástica │ 4.50 │ │ 28 │ Rössle Sauerkraut │ 45.60 │ │ 29 │ Thüringer Rostbratwurst │ 123.79 │ │ 42 │ Singaporean Hokkien Fried Mee │ 14.00 │ │ 53 │ Perth Pasties │ 32.80 │ └───────────┴───────────────────────────────┴───────────┘