MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / DataCollection

Class DataCollection

Solutions/2_6/colreader.py:6–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import csv
5
6class DataCollection(collections.Sequence):
7 def __init__(self, columns):
8 self.column_names = list(columns)
9 self.column_data = list(columns.values())
10
11 def __len__(self):
12 return len(self.column_data[0])
13
14 def __getitem__(self, index):
15 return dict(zip(self.column_names,
16 (col[index] for col in self.column_data)))
17
18
19def read_csv_as_columns(filename, types):

Callers 1

read_csv_as_columnsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected