Skip to content

Releases

FastCSV 1.0.0

Choose a tag to compare

@malcommac malcommac released this 08 Nov 22:27

First public release of FastCSV, a read-only CSV parser for Swift built for large files. No dependencies; runs on Apple platforms and Linux. Requires Swift 6.4.

Highlights

  • Streams the file through a fixed buffer, so memory stays flat whatever the file size. The buffer grows only for rows that need it.
  • Zero-copy typed accessors: intField, doubleField, boolField and timeField. doubleField matches Double(String) bit for bit, and timeField accepts hours above 24, as in GTFS.
  • RFC 4180 quoting, including delimiters, newlines and "" escapes inside quoted fields.
  • \n and \r\n line endings, and a leading UTF-8 BOM.
  • Row decoding through Decodable.

Benchmarks

Reading all 5,039,902 rows of a 235 MB GTFS stop_times.txt, with every field materialized as a String, on an Apple M3:

Parser Time Peak memory
FastCSV 0.741 s 6 MB
CSV.swift 2.5.2 8.259 s 6 MB
CodableCSV 0.6.7 9.989 s 6 MB
SwiftCSV 0.10.0 23.811 s 2,494 MB

The README covers the method, its caveats and how to reproduce the numbers.

Installation

.package(url: "https://github.com/malcommac/FastCSV.git", from: "1.0.0")

Known limits

FastCSV reads local UTF-8 files only and does not write CSV. rowCount scans the whole file on every access.