I don’t know if you have checked where in your code the EOF error is arising. As you have not mentioned it in, my guess would be that it's coming as you attempt to define df with, since that's the only place in your code where the file is getting read.
df = sqlContext.read.format('somethingspark.csv').options(header='true',
At every point after this line, your code is working with the variable df, not the file itself, therefore it is very likely that the error is getting generated in this line. A simple way to test if this is the case or not would be to comment out the rest of your code, and/or place a line like this right after the line above.