#This program reads the data in wunderdata.txt and writes it to wunderdata.xml in an XML form #wunderdata.txt is assumed to be a file where each line contains values, separated by a comma #The value in a row (that is the first value in a line of data) is assumed to be a date. #The next value (or values) is data. This code only outputs the date and first value. #NOTE: the third write below should be modified to indicate the proper value (min_temp, max_temp, average_temp, etc) import csv #Open the file to be written f = open('wunderdata.xml', 'w') #Read the data from the file to be read reader = csv.reader(open('wunderdata.txt', 'r'), delimiter=',') #Start output f.write('\n') #Write each row # the \n ends the line so that the next line starts on a new line for row in reader: f.write('\n') f.write('' + row[0] + '\n') f.write('' + row[1] + '\n') #change this line f.write('\n') #Finish output f.write('') #Close the file f.close()