File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 33# Exercise 3.3
44
55import csv
6+ import logging
7+
8+ log = logging .getLogger (__name__ )
69
710
811def 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 ))
Original file line number Diff line number Diff line change @@ -65,4 +65,12 @@ def main(args):
6565
6666if __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 )
You can’t perform that action at this time.
0 commit comments