Note that there are some explanatory texts on larger screens.

plurals
  1. POError in Reading File from mentioned Directory (Python 3.2)
    text
    copied!<p>For the Code posted below </p> <p>I have kept a notepad document called nd1.txt in the Folder C:\TempFiles</p> <pre><code>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() </code></pre> <p>Now whenever i'm executing the code, i get the following error msg</p> <pre><code>Traceback (most recent call last): File "E:\Documents\Information Retrieval\postingsList.py", line 39, in &lt;module&gt; 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 &lt;listcomp&gt; files = [open(f) for f in os.listdir('C:\TempFiles')] FileNotFoundError: [Errno 2] No such file or directory: 'nd1.txt' </code></pre> <p>Even though the file IS there in the mentioned folder, plus every function is working correctly, i've checked with dummy data</p> <p>Can anyone please tell me where my code went wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload