![]() I don't want spaces and need for the Issue ID column to only have the ID=u'number' data and the Name of issue to only have the POP Issue data. import csv import sys txtfile r'mytxt.txt' csvfile r'mycsv.csv' intxt open (txtfile, 'r') outcsv csv.writer (open (csvfile, 'wb')) filestring intxt.read () filelist filestring.split (' ') for row in ecfilelist: outcsv. ![]() This is what this code outputs - which is close but not quite right. Writer.writerow(('Name of Issue', 'Issue ID')) With open('newfile1.csv', 'w') as out_file: ![]() Lines = (line for line in stripped if line) Stripped = (line.strip() for line in in_file) With open('newfile1.txt', 'r') as in_file: The following code has worked to get the column names at the top of my CSV as well as splitting, but it is not in the right format and doesn't separate by ", ". The goal is to throw this into a CSV file that looks like the following with 2 columns: Name of issueīasically using the ", " in the txt file to act as a delimiter and separate the two into columns. My text document is in the following format: POP Issue: key=u'VPER-242', id=u'167782' I've been trying to convert a txt file to CSV but have been running into trouble.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |