What is the proper way to input file path name in the terminal? Should you type in the full path or something else? I wrote code that's supposed to check some sort of cardinality in files. But no matter how I input the path name it always spits out the same result (0:0). The code should be sound, but I'm thinking it's the path name I'm typing in wrong.
import os
wide_count = 0
long_count = 0
def card(file_name):
number_of_lines = 0
longest_line = 0
f = open(file_name, "r")
for line in f:
number_of_lines+= 1
if len(line) > longest_line:
longest_line = len(line)
f.close()
if longest_line > number_of_lines:
return 1
else:
return 0
directory = raw_input("Input file pathname: ")
for(current, sub, files) in os.walk(directory):
for f in files:
if card(os.path.join(current, files)) == 1:
wide_count += 1
else:
long_count += 1
print "{0:d} : {1:d}".format(wide_count, long_count)