In [1]:
import csv
import pprint
In [2]:
with open('data/src/sample_header.csv') as f:
print(f.read())
In [3]:
with open('data/src/sample_header.csv') as f:
reader = csv.DictReader(f)
l = [row for row in reader]
In [4]:
pprint.pprint(l)
In [5]:
print(l[1])
In [6]:
print(l[1]['c'])
In [7]:
with open('data/src/sample.csv') as f:
print(f.read())
In [8]:
with open('data/src/sample.csv') as f:
reader = csv.DictReader(f, fieldnames=['a', 'b', 'c', 'd'], )
for row in reader:
print(row)
In [9]:
with open('data/src/sample_header_index.csv') as f:
print(f.read())
In [10]:
with open('data/src/sample_header_index.csv') as f:
reader = csv.DictReader(f)
l = [row for row in reader]
In [11]:
pprint.pprint(l, width=100)
In [12]:
print([od.pop('') for od in l])
In [13]:
pprint.pprint(l)