| Conditions | 6 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | """Reads park millage input data from file.""" |
||
| 11 | def read(path): |
||
| 12 | """Parse a CSV flat file into an ordered dictionary.""" |
||
| 13 | |||
| 14 | parks = collections.OrderedDict() |
||
| 15 | |||
| 16 | log.info("reading %s...", path) |
||
| 17 | with open(path, 'r') as csvfile: |
||
| 18 | |||
| 19 | rows = csv.reader(csvfile) |
||
| 20 | |||
| 21 | header = None |
||
| 22 | for row in rows: |
||
| 23 | if not row: |
||
| 24 | continue |
||
| 25 | |||
| 26 | if header is None: |
||
| 27 | header = row |
||
| 28 | log.debug("header: %s", header) |
||
| 29 | else: |
||
| 30 | log.debug("row: %s", row) |
||
| 31 | data = AttributeDictionary() |
||
| 32 | name = row[0] |
||
| 33 | for index, key in enumerate(header): |
||
| 34 | data[key] = row[index] |
||
| 35 | parks[name] = data |
||
| 36 | |||
| 37 | log.info("read %s parks", len(parks)) |
||
| 38 | return parks |
||
| 39 |