import speedtest
import time
import csv
def test():
servers = []
s = speedtest.Speedtest()
s.get_servers(servers)
s.get_best_server()
s.download()
s.upload()
s.results.share()
results_csv = s.results.csv()
# csv_header = s.results.csv_header()
print(results_csv)
with open("results.csv", 'a') as f:
result_writer = csv.writer(f)
result_writer.writerow(results_csv)
time.sleep(120)
# 900
while True:
test()
This code returns csv formatted text to terminal perfectly I'm just having trouble writing it to the csv file I defined. How would I go about getting this to work properly?
Currently it prints the results with a comma after every digit/character and creates a new row for the next entry.