# CSV

Generic CSV lens collection

Author: Raphael Pinson raphael.nosp@m..pinson@camptoc.nosp@m.amp.com

Summary

CSV | Generic CSV lens collection
Reference | https://tools.ietf.org/html/rfc4180
License | This file is licenced under the LGPL v2+, like the rest of Augeas.
Lens Usage | To be documented
Configuration files |
Examples | The <Test_CSV> file contains various examples and tests.
Augeas Lenses |
eol |
comment |
entry | An entry of fields, quoted or not
lns | The generic lens, taking the separator as a parameter
lns | The comma-separated value lens
lns_semicol | A semicolon-separated value lens

### Reference

https://tools.ietf.org/html/rfc4180

### License

This file is licenced under the LGPL v2+, like the rest of Augeas.

### Lens Usage

To be documented

### Configuration files

### Examples

The <Test_CSV> file contains various examples and tests.

#### Caveats

No support for files without an ending CRLF

### Augeas Lenses

### eol

> let eol = Util.del_str "\n"

### comment

> let comment = Util.comment | [ del /#[ \t]*\r?\n/ "#\n" ]

### entry

> let entry (sep_str:string) = let field = [ seq "field" . store (/[^"#\r\n]/ - sep_str)* ] | [ seq "field" . store /("[^"#]*")+/ ] in let sep = Util.del_str sep_str in [ seq "entry" . counter "field" . Build.opt_list field sep . eol ]

An entry of fields, quoted or not

### lns

> let lns_generic (sep:string) = (comment | entry sep)*

The generic lens, taking the separator as a parameter

### lns

> let lns = lns_generic ","

The comma-separated value lens

### lns_semicol

> let lns_semicol = lns_generic ";"

A semicolon-separated value lens

> let eol = Util.del_str "\n"

> let comment = Util.comment | [ del /#[ \t]*\r?\n/ "#\n" ]

> let entry (sep_str:string) = let field = [ seq "field" . store (/[^"#\r\n]/ - sep_str)* ] | [ seq "field" . store /("[^"#]*")+/ ] in let sep = Util.del_str sep_str in [ seq "entry" . counter "field" . Build.opt_list field sep . eol ]

An entry of fields, quoted or not

> let lns_generic (sep:string) = (comment | entry sep)*

The generic lens, taking the separator as a parameter

> let lns_semicol = lns_generic ";"

A semicolon-separated value lens
Close