0

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)
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Aaron
  • 3
  • 3

0 Answers0