| 152 | |
| 153 | if headers.len() < 2 { |
| 154 | return Err(EtfTrickError::TooFewColumns { path: path.display().to_string() }); |
| 155 | } |
| 156 | |
| 157 | let columns = headers.iter().skip(1).map(ToString::to_string).collect::<Vec<_>>(); |
| 158 | let mut index = Vec::new(); |
| 159 | let mut values = Vec::new(); |
| 160 | |
| 161 | for rec in rdr.records() { |
| 162 | let record = rec.map_err(|e| EtfTrickError::csv("read record", path, e))?; |
| 163 | let (idx, row) = parse_row(&record, path)?; |
| 164 | index.push(idx); |
| 165 | values.push(row); |
| 166 | } |
| 167 | |
| 168 | Ok(Self { index, columns, values }) |
| 169 | } |
| 170 | |