ddsv 0.5.0
A toy delimiter separated text parser
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
D-DSV
Toy implementation of a simplistic delimiter separated value parser library in D. Made for the purpose of getting familiar with D as a language.
Features
- Input\ One or more lines/chunks of text.
- Output\ Currently parses input into a multi-dimensional array of strings.
- Controllable text delimiters\
Defaults to
"
- Controllable field delimiters\
Defaults to
,
Usage
Line by Line from stdin
import std.stdio;
import dsv;
void main(string[] args){
Parser tsv = new ParserBuilder().fieldDelimiter('\t').build();
string line;
while ((line = stdin.readln()) !is null)
tsv.parse(line);
writeln(tsv.finish());
}
$ echo -n "foo\tbar\tfoobar\r\n\"fizz\"\t\t\"buzz\"\rping\tpong\n\tcat\t\"dog\"" | dub run
[["foo", "bar", "foobar"], ["fizz", "", "buzz"], ["ping", "pong", ""], ["", "cat", "dog"]]
Arbitrarily chunked input
import std.stdio;
import dsv;
void main(string[] args){
Parser tsv = new ParserBuilder().fieldDelimiter('\t').build();
string line;
tsv.parse("foo\tbar\tfoobar\r\n\"fi");
tsv.parse("zz\"\t\t\"buzz\"");
tsv.parse("\rping\tpong\n\tcat\t\"dog\"\n\n\n\n");
writeln(tsv.finish());
}
$ dub run
[["foo", "bar", "foobar"], ["fizz", "", "buzz"], ["ping", "pong", ""], ["", "cat", "dog"]]
TODO
- Handle headers Current implementation treats headers as regular text
- Reduce buffer reallocations:: Field string buffer is reallocated per field character
- Clean up
dsv.Parser
implementation:: 'cause damn
- Registered by Elizabeth Harper
- 0.5.0 released 6 years ago
- Foxcapades/d-dsv
- github.com/foxcapades/dsv
- MIT
- Authors:
- Dependencies:
- none
- Versions:
-
0.7.0 2018-Mar-30 0.6.0 2018-Mar-29 0.5.0 2018-Mar-28 0.4.0 2018-Mar-27 0.3.0 2018-Mar-24 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
17 downloads total
-
- Score:
- 0.3
- Short URL:
- ddsv.dub.pm