With the following (note the first row has no leading space):
Test1@bigfoot.com
Test11@bigfoot.com
Test1111@bigfoot.com
Test111ew@bigfoot.com
Test12312@bigfoot.com
Test1231321@bigfoot.com
Test1342321@bigfoot.com
....
481 total rows
The following correctly removes the leading space, but inserts a blank row after each string row, AND, truncates the total list by a random number of rows each time it is executed.
csvfile= open('list.csv','r')
csvfile1= open('complete_list.csv','w')
stripped = (row.strip() for row in csvfile)
reader = csv.reader(stripped,delimiter=' ')
writer= csv.writer(csvfile1)
for row in reader:
writer.writerow([e.strip() for e in row])
And:
with open('list.csv') as infile:
reader = csv.DictReader(infile)
fieldnames = reader.fieldnames
for row in reader:
row.update({fieldname: value.strip() for (fieldname, value) in row.items()})
Does nothing, as the first row is assumed to be the fieldname, when in fact it is simply...a row.