ddsv 0.1.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 :source-highlighter: pygments Elizabeth Harper foxcapade@gmail.com v1.0, March 24, 2018

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

[source,d]

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()); }

[source,bash]

$ 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

[source,d]

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()); }

[source,bash]

$ 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 Normalize row sizes::

This applies more to the current implementation or 'headerless' mode. Presently row sizes follow this rule: + a row will be the same size or larger than the row before it + This means the output arrays can be inconsistent in size like the following: +

[["1.1"],["2.1","2.2"]]

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
Show all 10 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 17 downloads total

Score:
0.3
Short URL:
ddsv.dub.pm