I've been struggling to open some files in python from a text file with a list of strings that are file names: for example the .txt file would contain a list of names like the following r'c:\users\computer\documents\example.txt'
I want to run a loop that looks at each line and sees if 'example' is in the line. If so I want to open(line), however I cannot, and get a OSError: [Errno 22] Invalid argument:
If I manually type the file name in I can open it, but the variable will not open it. I tried assigning a variable to line, replacing '\n' trying StringIO, but getting nowhere. I'm assuming its because python is looking at the variable as a string object and needs a file object. But how do I make the string line into a file object of the same name. Thanks