A storage that writes to csv files
CsvDictStorage constructor
| Param: |
|
|---|---|
| Raises: | ApeError if neither path nor storage given |
CsvDictStorage constructor
| Param: |
|
|---|---|
| Raises: | ApeError if neither path nor storage given |
Methods
| __init__(headers[, path, storage]) | CsvDictStorage constructor |
| log_error(error[, message]) | Logs the error in bold red |
| open(filename) | Opens the filename as a DictWriter |
| writerow(rowdict) | Writes the row to storage |
| writerows(rowdicts) | Writes each dictionary in rowdicts to the csv |
Attributes
| logger |
|
||
| storage | A file-storage created from the path (unless passed into constructor) | ||
| writer | DictWriter instance (creates it if not set) |
Logs the error in bold red
| Param: |
|
|---|
Opens the filename as a DictWriter
| Param: |
|
|---|---|
| Postcondition: | header written to file |
| Returns: | copy of self with open DictWriter as writer |
Writes the row to storage
| Param: |
|
|---|---|
| Raise: | ApeError if keys don’t match header or invalid data was passed in. |
Writes each dictionary in rowdicts to the csv
| Param: |
|
|---|---|
| Raise: | ApeError (see writerow) |
| Returns: | A logging object. |
|---|
A file-storage created from the path (unless passed into constructor)
| Returns: | FileStorage |
|---|
DictWriter instance (creates it if not set)
| Postcondition: | if dictwriter created, header written to file |
|---|---|
| Raise: | ApeError if not set and storage not writeable |