Txt to csv script adapted from openfile.py