diff options
| author | Julian Hurst <ark@mansus.space> | 2024-11-15 01:14:07 +0100 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2024-11-15 01:14:07 +0100 |
| commit | 189c3af4052d543ce816637d97fed926fefa5c47 (patch) | |
| tree | 3e04183827064e52aeb954c5495a283c9f6ff2c6 /csv | |
| parent | e2bee01af84bc7a6bc191f931f195b3c0b5175cc (diff) | |
| download | hatask-189c3af4052d543ce816637d97fed926fefa5c47.tar.gz | |
csv -> tsv
Diffstat (limited to 'csv')
| -rw-r--r-- | csv/csv.ha | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/csv/csv.ha b/csv/csv.ha deleted file mode 100644 index 40e1e3b..0000000 --- a/csv/csv.ha +++ /dev/null @@ -1,30 +0,0 @@ -use io; -use strings; -use fmt; - -export type error = !(str | io::error); - -export fn writerecord(w: io::handle, record: []str, separator: const str = ",", quote: const rune = - '"') (void | error) = { - let sep = ""; - for (const field .. record) { - if (strings::contains(field, separator)) { - if (strings::contains(field, quote)) { - return "ERROR: Field contains quote character - (not supported)"; - }; - fmt::fprintf(w, "{}{}{}{}", sep, quote, field, quote)!; - } else { - fmt::fprintf(w, "{}{}", sep, field)!; - }; - sep = separator; - }; - fmt::fprintln(w)!; -}; - -export fn writerecords(w: io::handle, records: [][]str, separator: const str = ",", quote: const - rune = '"') (void | error) = { - for (const record .. records) { - writerecord(w, record, separator, quote)?; - }; -}; |
