And now I cannot load the files that I’m using. I’m accessing them using the following code:
I get a “no such file or directory” error, although I know the file is in the right place. I’m getting the feeling that it might be because MYDIR is set to “/c/Documents and Settings/cjh294/My Documents/project” instead of what it would be if I set it “manually”, “/Documents and Settings/cjh294/My Documents/project”. Is there a way to get rid of the “/c”? If that is not the problem, any other thoughts?
Thanks in advance for the help.
EDIT #1: After not being a bum and actually looking for a solution, I found it in the python manual. Merely deleting the second line of the MYDIR creation code solved the problem.
EDIT #2: Well, isn’t this interesting, although should have been expected. It seems that loading Panda files (models etc.) takes a different path format than the file object native to python. My models stopped loading after I deleted the line before. I solved it by created two directory variables. Perhaps this can be changed in future releases?
We have established an “unusual” filename convention for Panda to aid portability to non-Windows platforms. See Panda Filename Syntax in the manual. If you restrict yourself to Panda I/O functions, you can use the Panda filename syntax exclusively, and your application can run without modification on Windows, Linux, or (one day) OSX.
Of course, it’s handy to use Python functions for I/O as well, but Python doesn’t know about Panda’s filename syntax. This means you can either keep two different variables around, as you have done, or you can convert back and forth when you need to by using, for instance, filename.toOsSpecific().
Ah I see. It does of course make perfect sense. I don’t think in very large terms it seems . More out of curiosity, are there any built-in panda functions for loading more general purpose files (the one I am using is a .txt, although I suppose .py is very similar)?
You can read .txt files (or binary files of your own devising) using vfs.readFile(), if you like; this also has the advantage that it can directly read files that are stored in a .mf file mounted using the vfs-mount config variable; it can also automatically unzip pzipped (.pz) files. It’s not quite as robust a read interface as Python’s read(), though–you can only read the whole file all at once.
I don’t think there’s a Panda interface for writing files, though, so you’ll have to go through Python for that.