3 Generic CSV lens collection
5 Author: Raphael Pinson <raphael.pinson@camptocamp.com>
8 https://tools.ietf.org/html/rfc4180
11 This file is licenced under the LGPL v2+, like the rest of Augeas.
16 About: Configuration files
19 The <Test_CSV> file contains various examples and tests.
22 No support for files without an ending CRLF
27 let eol = Util.del_str "\n"
30 let comment = Util.comment
31 | [ del /#[ \t]*\r?\n/ "#\n" ]
34 An entry of fields, quoted or not *)
35 let entry (sep_str:string) =
36 let field = [ seq "field" . store (/[^"#\r\n]/ - sep_str)* ]
37 | [ seq "field" . store /("[^"#]*")+/ ]
38 in let sep = Util.del_str sep_str
39 in [ seq "entry" . counter "field" . Build.opt_list field sep . eol ]
42 The generic lens, taking the separator as a parameter *)
43 let lns_generic (sep:string) = (comment | entry sep)*
46 The comma-separated value lens *)
47 let lns = lns_generic ","
50 A semicolon-separated value lens *)
51 let lns_semicol = lns_generic ";"