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():
7
7
check_csv (filename )
8
8
9
9
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 ))
14
14
for row in reader :
15
15
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
+
17
20
except FileNotFoundError :
18
21
exit ('File does not exist' )
19
22
except Exception as arg :
@@ -24,13 +27,13 @@ def get_filename(arguments):
24
27
if len (arguments ) < 2 :
25
28
exit ('Too few command-line arguments' )
26
29
else :
27
- exit ('Too mant command-line arguments' )
28
- return argv [1 ]
30
+ exit ('Too many command-line arguments' )
31
+ return arguments [1 ]
29
32
30
33
def check_csv (filename ):
31
34
dot = filename .find ('.' )
32
35
if filename [dot :] != '.csv' :
33
36
exit ('Not a CSV file' )
34
37
35
38
if __name__ == '__main__' :
36
- main ()
39
+ main ()
You can’t perform that action at this time.
0 commit comments