I am trying to read in an ascii delimited text file that has been parsed, and the SPACE characters have been replaced with the ',' (comma) character. I next need to convert this information to two columns and save it back to another file that I can bring into Microsoft Word.
Below is a sample of the information from the delimited file. Any help you can give me is appreciated. P.S. I am using Python 3.8. I'm new to python programming, or can't you tell! -Thanks!
(Sample of flat file, one long line...):
Package,Version,------------------------,---------,backcall,0.2.0,beautifulsoup4,4.9.3,cachetools,4.1.1,certifi,2020.6.20,chardet,3.0.4,cloudpickle,1.6.0,colorama,
What I have tried:
import os
# Works so far!
os.chdir('C:/')
CurrentDIR = os.getcwd()
# Works so far!
MyFile = open('C:/List.csv', 'rt')
MyString = MyFile.read()
MyFile.close()
def remove(MyString):
return ",".join(MyString.split())
OutputFile = open(r'c://users//larry//Output.txt','w')
OutputFile.write(remove(MyString))
OutputFile.close()