I have a script that creates files for each line of a CSV file. However, somehow a blank line is being added to the end of the newly created file.
Code:
with open(fullCSV, 'r') as f:
reader = csv.reader(f)
csvList = list(reader)
for item in csvList:
if not os.path.exists(tempLoc + item[0]):
os.mkdir(tempLoc + item[0])
with open(tempLoc + item[0] + r"\prm.263", "w+") as f:
csv.writer(f).writerow(item[1:])
f.close
Is there some way I can strip the blank line on creation?
Thanks in advance
Edit:
Here is the sample of 1 of the output files that is being created 
Here is the CSV file its reading 
from Removing blank lines while creating file
No comments:
Post a Comment