Fix 5_1 and 5_3
This commit is contained in:
@@ -115,7 +115,7 @@ kinds of input sources. For example:
|
||||
```python
|
||||
>>> import gzip
|
||||
>>> import stock
|
||||
>>> file = gzip.open('Data/portfolio.csv.gz')
|
||||
>>> file = gzip.open('Data/portfolio.csv.gz', 'rt')
|
||||
>>> port = reader.csv_as_instances(file, stock.Stock)
|
||||
>>> port
|
||||
[Stock('AA', 100, 32.2), Stock('IBM', 50, 91.1), Stock('CAT', 150, 83.44),
|
||||
|
||||
@@ -48,11 +48,10 @@ def read_csv_as_instances(filename, cls, *, headers=None):
|
||||
import csv
|
||||
|
||||
def convert_csv(lines, converter, *, headers=None):
|
||||
records = []
|
||||
rows = csv.reader(lines)
|
||||
if headers is None:
|
||||
headers = next(rows)
|
||||
return map(lambda row: converter(headers, row), rows)
|
||||
return list(map(lambda row: converter(headers, row), rows))
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user