Blender not accepting CSV file
In the first example, you tell the open function to ignore errors with open(..., 'ignore') . If a file is not found, it will have the behavior that you mentioned:

TypeError: an integer is required (got type str)


Also, the U mode is deprecated, so you probably shouldn't be using it.

A reasonable possibility is that where you are running it in Blender, the current working directory is different than what you think it is. Try printing out the result of os.getcwd() and os.listdir() like so:

import os

print(os.getcwd())   # current directory
print(os.listdir())  # files in current directory