Extract data from multiple text files
Albert-Jan Roskam
sjeik_appie at hotmail.com
Tue May 15 08:46:16 EDT 2018
On May 15, 2018 14:12, mahesh d <mahesh.tech88 at gmail.com> wrote:
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
--
https://mail.python.org/mailman/listinfo/python-list
Try:
path = 'C:/Users/A-7993/Desktop/task11/sample emails/*.msg'
msg_files = glob.glob(path)
print(msg_files)
More information about the Python-list
mailing list