File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,16 @@ def main():
77 check_csv (filename )
88
99 try :
10- with open (filename ,'r' ) as file :
11- reader = csv .reader (file )
12- table = []
13- headers = list (next (reader ))
10+ with open (filename , 'r' ) as file :
11+ reader = csv .reader (file )
12+ table = []
13+ headers = list (next (reader ))
1414 for row in reader :
1515 table .append ([row [0 ], row [1 ], row [2 ]])
16- print (tabulate (table , headers , tablefmt = "grid" ))
16+
17+ # Move print statement outside the loop
18+ print (tabulate (table , headers , tablefmt = "grid" ))
19+
1720 except FileNotFoundError :
1821 exit ('File does not exist' )
1922 except Exception as arg :
@@ -24,13 +27,13 @@ def get_filename(arguments):
2427 if len (arguments ) < 2 :
2528 exit ('Too few command-line arguments' )
2629 else :
27- exit ('Too mant command-line arguments' )
28- return argv [1 ]
30+ exit ('Too many command-line arguments' )
31+ return arguments [1 ]
2932
3033def check_csv (filename ):
3134 dot = filename .find ('.' )
3235 if filename [dot :] != '.csv' :
3336 exit ('Not a CSV file' )
3437
3538if __name__ == '__main__' :
36- main ()
39+ main ()
You can’t perform that action at this time.
0 commit comments