Summaries/Python/Algemeen/csv.md

24 lines
387 B
Markdown
Raw Normal View History

2022-08-09 21:04:44 +02:00
```python
import csv
%precision 2
with open('../datasets/mpg.csv') as csvfile:
mpg = list(csv.DictReader(csvfile))
```
2024-02-21 22:09:32 +01:00
2022-08-09 21:04:44 +02:00
output gives dict with key the row number:
[{'': '1',
'manufacturer': 'audi',
'model': 'a4',
'displ': '1.8',
'year': '1999',
'cyl': '4',
'trans': 'auto(l5)',
'drv': 'f',
'cty': '18',
'hwy': '29',
'fl': 'p',
'class': 'compact'},
{'': '2',