I have a list that has this form
[['url', 'date', 'extractRaw', 'extractClean'], ['https://www.congress.gov/crec/2017/01/09/CREC-2017-01-09-senate.pdf', '20170109', 'UR\n\nIB\nU\n\nU\n\nE PL\n\nNU\n\nCo', '20170109', 'URIBUUE PLNUCo'], ['https://www.congress.gov/crec/2017/01/09/CREC-2017-01-09-senate.pdf', '20170109', 'UR\n\nIB\nU\n\nU\n\nE PL\n\nNU\n\nCo', '20170109', 'UURIBUUE PLNUCo']]
I'm exporting it to a CSV with this code
def exportCSV(flatList, filename):
with open(filename+".csv", "wb") as f:
writer = csv.writer(f)
writer.writerows(flatList)
exportCSV(textExport,'textExport')
This version follows the new line and I end up with a CSV that reads to a new line for every one of the \n
symbols.
My desire is to get each entry in the list on its own separate line. It would look something like this
url date extractRaw extractClean
https://www.congress.gov/crec/2017/01/09/CREC-2017-01-09-senate.pdf 20170109 UR\n\nIB\nU\n\nU\n\nE PL\n\nNU\n\nCo URIBUUE PLNUCo
https://www.congress.gov/crec/2017/01/09/CREC-2017-01-09-senate.pdf 20170109 UR\n\nIB\nU\n\nU\n\nE PL\n\nNU\n\nCo URIBUUE PLNUCo
https://www.congress.gov/crec/2017/01/09/CREC-2017-01-09-senate.pdf 20170109 UR\n\nIB\nU\n\nU\n\nE PL\n\nNU\n\nCo URIBUUE PLNUCo
Does writer.writerows()
support that? Can I get it to ignore the new line symbols?
It's not a duplicate. The \n
is part of the block of text and the file is opened as 'wb'
.