For the Code posted below
I have kept a notepad document called nd1.txt in the Folder C:\TempFiles
import os,file,storage
database = file.dictionary()
tools = storage.misc()
lui = -1
def sendWord(wrd, findex):
global lui
if findex!=lui:
tools.refreshRecentList()
lui = findex
if tools.mustIgnore(wrd)==0 and tools.toRecentList(wrd)==1:
database.addWord(wrd,findex)
def showPostingsList():
database.display()
def parseFile(nfile, findex):
for line in nfile:
pl = line.split()
for word in pl:
print(word)
sendWord(word.lower(),findex)
def parseDirectory():
files = [open(f) for f in os.listdir('C:\TempFiles')]
findex = 0
for nf in files:
parseFile(nf,findex)
findex+=1
def main():
parseDirectory()
showPostingsList()
main()
Now whenever i'm executing the code, i get the following error msg
Traceback (most recent call last):
File "E:\Documents\Information Retrieval\postingsList.py", line 39, in <module>
main()
File "E:\Documents\Information Retrieval\postingsList.py", line 36, in main
parseDirectory(dirname)
File "E:\Documents\Information Retrieval\postingsList.py", line 28, in parseDirectory
files = [open(f) for f in os.listdir('C:\TempFiles')]
File "E:\Documents\Information Retrieval\postingsList.py", line 28, in <listcomp>
files = [open(f) for f in os.listdir('C:\TempFiles')]
FileNotFoundError: [Errno 2] No such file or directory: 'nd1.txt'
Even though the file IS there in the mentioned folder, plus every function is working correctly, i've checked with dummy data
Can anyone please tell me where my code went wrong?