Extract data from multiple text files

mahesh d mahesh.tech88 at gmail.com
Tue May 15 08:12:52 EDT 2018


import glob,os

import errno

path = 'C:/Users/A-7993\Desktop/task11/sample emails/'

files = glob.glob(path)

'''for name in files:

    print(str(name))

    if name.endswith(".txt"):

           print(name)'''

for file in os.listdir(path):

    print(file)

    if file.endswith(".txt"):

        print(os.path.join(path, file))

        print(file)

        try:

            with open(file) as f:

                msg = f.read()

                print(msg)

        except IOError as exc:

            if exc.errno != errno.EISDIR:

                raise


In the above program . Getting lot of errors . My intention is read the
list of the text files in a folder . Print them


 How can resolve those error



More information about the Python-list mailing list