csv2struct
Generates struct definitions from CSV using some very basic rules.
```bash $ cat test.csv foo,bar,baz,qux 1,2,3,green 4.4,5,6,red 7.2,,8,blue
$ cat test.csv | csv2struct
pub struct Record {
pub foo: f32,
pub bar: Option
pub enum Qux { Green, Red, Blue, } ```
There are two sets of rules at play. First, we apply the following set of rules to each value in each column and record the results.
if value == "" => Empty
if let Some(_) = value.parse::<i32>() => Integer
if let Some(_) = value.parse::<f32>() => Real
else => Factor(value)
Next, we apply the following rules to the results for each column:
Option
.Finally, we generate a struct definition with one field for each column. For factors, we generate an enum as well.