I have a bunch of comma-delimited files that I am trying to change to pipe-delimited files.
I am following the example provided here: Python CSV change separator
Here is my code:
print("setting new delimiter...")
reader = list(csv.reader(open(localfile, "rU"), delimiter=','))
writer = csv.writer(open(localfile, 'w'), delimiter='|', lineterminator='\n')
writer.writerows(row for row in reader)
I can't tell if memory usage is cumulative, or because of a specific filesize, but either way, on my third file, I get a memory error
.
since the third file is nearly the same size as the first two, it appears cumulative.
Is there a better way in doing this? Thanks