PHP Notice: Undefined offset: 1 with array when reading data

Change to or simply: Not every line of your file has a colon in it and therefore explode on it returns an array of size 1. According to php.net possible return values from explode: Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter. If delimiter is an empty string … Read more

Python giving FileNotFoundError for file name returned by os.listdir

It is because os.listdir does not return the full path to the file, only the filename part; that is ‘foo.txt’, when open would want ‘E:/somedir/foo.txt’ because the file does not exist in the current directory. Use os.path.join to prepend the directory to your filename: (Also, you are not closing the file; the with block will take care of it automatically).