Skip to content

Commit cf40423

Browse files
committed
Done 8.2 and 8.3
1 parent e9e4e6b commit cf40423

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Work/fileparse.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Exercise 3.3
44

55
import csv
6+
import logging
7+
8+
log = logging.getLogger(__name__)
69

710

811
def parse_csv(
@@ -35,8 +38,8 @@ def parse_csv(
3538
row = [func(val) for func, val in zip(types, row)]
3639
except ValueError as e:
3740
if not silence_errors:
38-
print(f'Row {idx}: Couldn\'t convert {row}')
39-
print(f'Row {idx}: Reason {e}')
41+
log.warning(f'Row {idx}: Couldn\'t convert {row}')
42+
log.debug(f'Row {idx}: Reason {e}')
4043
continue
4144
if headers:
4245
record = dict(zip(headers, row))

Work/report.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,12 @@ def main(args):
6565

6666
if __name__ == '__main__':
6767
import sys
68+
import logging
69+
70+
logging.basicConfig(
71+
filename='app.log',
72+
filemode='w',
73+
level=logging.DEBUG,
74+
)
75+
6876
main(sys.argv)

0 commit comments

Comments
 (0)