Need help?
Ask a question or report a problem on GitHub.
Open an issue
CSV and downloads
Otter reads and writes RFC 4180 CSV natively. Each column header becomes a property of a row object.
Otter
rawCsv is "id,city,temp\n101,Seattle,68\n102,Portland,72\n103,Spokane,75" convert rawCsv from csv into records say "Loaded" length of records "weather records:" each row in records say " City:" city of row "High:" temp of row .
Output
Loaded 3 weather records: City: Seattle High: 68 City: Portland High: 72 City: Spokane High: 75
Reading and writing CSV files
Otter
filePath is "weather.csv" write csv records to filePath read csv from filePath into loadedData say "Verified" length of loadedData "rows read from disk." delete file filePath
Downloading files
download streams a file from an HTTP or HTTPS address to a local path:
Otter
url is "https://httpbin.org/robots.txt" dest is "robots.txt" download file from url to dest if file dest exists read dest into text say "Downloaded" length of text "bytes." delete file dest .
Built-in download safety
Otter never silently overwrites an existing file - the download stops before making any network request. Data streams into a hidden temporary file and is renamed into place only after every byte arrives. If the connection drops or the transfer is truncated, the partial file is removed.
Next: networking