I have the following code to read files on the folder, which seems to be working fine with print(line)
, but it brings only one line while calling it through a variable (line
). What am I doing wrong here?
import fileinput
import glob
folderpath = r"\path\*"
file_list = glob.glob(folderpath + "/*.txt")
with fileinput.FileInput(files=(file_list), mode='r') as f:
for line in f:
#line = line.decode()
line = line.rstrip()
print(line)