Good morning friends,
I am having a weird little issue with python that I am certain stems from me failing to understand wtf is going on.
I will give you the general disclaimer that I am a total programming beginner so I'll need some latitude :)
The following snippet is a function I am working on for a larger project that I can't seem to figure out.
The idea is to have python grab all the names of the files in the directory, open them in turn and print the results on screen.
import OS
path = "/home/blahblah/Desktop/projData/"
projData = os.listdir(path)
while (i <= 300):
for file in projData[i]:
openedfile = open("/home/blahblah/Desktop/projData/" + file)
i + 1
print openedfile
I figured this was pretty straight forward but I was getting I/O errors that the files that it pulled didn't exist.
I've isolated it down to it being when the contents of "file" is appended to the string something funny happens that it doesn't like.
For example, let's say the first file in the directory is named '1', if I run the script I get an I/O error that says '/home/blahblah/Desktop/projData/1' doesn't exist, but if I type the one by hand into '/home/blahblah/Desktop/projData/1' then the file opens just fine.
Obviously there's something I am not understanding! Any help\constructive criticism would be greatly appreciated.
Thanks for your time.