I'm comparing two files and writing difference to a third file.
I'm not able to open the files because (possibly) there is a \r
in the path name.
This is being run on a work computer and my username is robk that I think is the problem.
The Error:
OSError: [Errno 22] Invalid argument: Users\robk\\Downloads\\AR_New_Records.csv'
Here is my code. The problem comes from two last lines.
def read_items(filename):
with open(filename) as fh:
return {line.strip() for line in fh}
def diff_string(old, new):
return "\n".join(
['[-] %s' % gone for gone in old - new] +
['[+] %s' % added for added in new - old]
)
with open('Users\robk\Downloads\AR_New_Records.csv', 'w') as fh:
fh.write(diff_string(read_items('Users\robk\Downloads\latestroster.csv')), read_items('Users\robk\Downloads\oldroster.csv'))
Any help would be appreciated!