import csv
from psyFunction import psych
head_judge = True
with open("weatherdata.csv", 'rt') as fileread:
with open("add_wb.csv", 'wt') as filewrite:
filereader = csv.reader(fileread)
filewriter = csv.writer(filewrite)
for i in filereader:
print(i)
if head_judge:
m = ["wb","W"]
for n in m:
i.append(n)
filewriter.writerow(i)
head_judge = False
else:
a_1, a_2 = psych(float(i[3]),float(i[11]))
a_1 = str(a_1); a_2 = str(a_2)
i.append(a_1)
i.append(a_2)
filewriter.writerow(i)
This is my code that reads the weather data(dry bulb and relative humidity) and calculates web bulb temperature and absolute humidity and adds the new calculated results to the existing data. psyFunction is the code I made. It works well except that blank lines are added to the csv file one line at a time. The odd thing is that when I open output file in notepad, there is no blank line, which means I have an empty line when I open it in Notepad++ or in Excel. What's the problem? The input file doesn't have problem.