Go ahead!

Memoization for Everything

LTSV for D

| Comments

In this week, Shinji Tanaka announced Labeled Tab-separated Values (LTSV). LTSV is the flexible and robust row oriented format.

I just implemented ltsv-d for D programming language.

LTSV for D

ltsv-d provides fromLTSV and toLTSV functions.

fromLTSV for parsing:

1
2
3
auto apacheLog = "host:127.0.0.1\tident:-\tuser:foo\ttime:[10/Oct/2000:13:55:36 -0700]\treq:GET /apache.gif HTTP/1.0\tstatus:200\tsize:777\treferer:http://www.example.com/start.html\tua:Mozilla/4.08 [en] (Win98; I ;Nav)";
auto record = fromLTSV(apacheLog);
writeln(record["host"]); // "127.0.0.1"

toLTSV for dumping:

1
2
auto line = ["foo":"bar", "hoge":"fuga", "piyo":"puyo"].toLTSV();
writeln(line); // "foo:bar\thoge:fuga\tpiyo:puyo"

Enjoy LTSV!

Comments