# Avoid notebook's error while reading a text file in Raspberry Pi?

Posted 5 months ago
637 Views
|
2 Replies
|
1 Total Likes
|
 I ported a working notebook from my computer to RPi where Mathematica was pre-installed. It starts nicely, but stops as it tries to read a simple text file. The very first lines are these: $HomeDirectory /home/pi dict0 = ToString /@ ReadList["sv_JSPFirefoxRensadCRUTF-8.txt"] ReadList::noopen: Cannot open sv_JSPFirefoxRensadCRUTF-8.txt.$Failed I have not changed anything, same text file etc. Any suggestions would be much appreciated. Thank you very much in advance.
2 Replies
Sort By:
Posted 4 months ago
 The error message usually indicates that Mathematica cannot find the file you ask it to read. ReadList will import from the directory specified by Directory[] not $HomeDirectory.In[6]:=$HomeDirectoryDirectory[]Out[6]= "C:\Users\epark"Out[7]= "C:\Users\epark\Documents"If the file is in the wrong spot, then ReadList will not be able to find it. You can set the working directory by SetDirectory. For example, SetDirectory[NotebookDirectory[]] will set the directory of the current evaluation notebook as the working directory.
 Thank you, Eun! So my solution was to write SetDirectory[NotebookDirectory[]] Assuming that the files are in the same folder (directory) as the notebook itself. It all works nicely.