I have a text file, Text.txt where each line looks like this:
1, 2, 3, 4, name.docx, , 5, 6, 7
Where the numbers change from one line to the next, but not name.docx (and yes, that space between name and 5 was intentional). I'm looking to change the fifth comma (that is, the one after the "name.docx") to another character, i.e. "@" - but I need to do this for every line. How might this be done?
Note: I know that something like this, for some string, can be used to change the nth occurence of a certain character in a line to another (in this case a comma with "@"):
re.sub(r'^((.*?,.*?){n}),', r'\1@', mystring)
However I don't know the most efficient way to apply this to all lines.