Hello guys,
With the following code I'm exporting my data to a CSV file:
How can I fix it, and get the values on my csv file without the blank line?
Thank you!
With the following code I'm exporting my data to a CSV file:
from tempfile import NamedTemporaryFile
from FlightRadar24.api import FlightRadar24API
from time import time, sleep
from datetime import datetime
import shutil
import csv
import threading
import schedule
import time
import sched, time
s = sched.scheduler(time.time, time.sleep)
def do_something(sc):
print("Doing stuff...")
now = datetime.now()
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
company1 = len(fr_api.get_flights(airline = 'AZU'))
company2 = len(fr_api.get_flights(airline = 'GLO'))
company3 = len(fr_api.get_flights(airline = 'LAN'))
company4 = len(fr_api.get_flights(airline = 'PTB'))
print(dt_string, company1, company2, company3, company4)
fields=[dt_string,company1,company2,company3,company4]
with open(r'C:\Users\bruno\Desktop\Voos\Voos.csv', 'a') as f:
writer = csv.writer(f, delimiter=';')
writer.writerow(fields)
s.enter(60, 1, do_something, (sc,))
s.enter(60, 1, do_something, (s,))
s.run()When I print it, I get the values line by line... print(dt_string, company1, company2, company3, company4) 23/03/2021 09:09 50 18 34 1 23/03/2021 09:09 50 18 34 1 23/03/2021 09:09 50 19 34 1 23/03/2021 09:09 50 19 34 1 23/03/2021 09:09 50 19 34 1 23/03/2021 09:09 51 19 34 1 23/03/2021 09:09 51 19 34 1 23/03/2021 09:09 51 19 34 1But when I open my csv file, the results are separated by an empty line... like this:
23/03/2021 09:09 50 18 34 1 23/03/2021 09:09 50 18 34 1 23/03/2021 09:09 50 19 34 1 23/03/2021 09:09 50 19 34 1 23/03/2021 09:09 50 19 34 1 23/03/2021 09:09 51 19 34 1 23/03/2021 09:09 51 19 34 1 23/03/2021 09:09 51 19 34 1What's going on?
How can I fix it, and get the values on my csv file without the blank line?
Thank you!
