outfile = open('fakedata.csv', 'w') outfile.write("timestamp,value\n") for i in range(20): outfile.write("{},{}\n".format(i, i**2)) outfile.close()