# Written by Francois Fleuret <francois@fleuret.org>
 
-import os, time, math
+import os, time
 import numpy, csv
 import matplotlib.pyplot as plt
 import matplotlib.dates as mdates
 
 url = 'https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv'
 
-file = 'time_series_19-covid-Confirmed.csv'
+file = url[url.rfind('/')+1:]
 
 ######################################################################
 
                     nb_cases[country] = numpy.zeros(len(times))
             if row_nb == 0 and col_nb >= time_col:
                 times.append(time.mktime(time.strptime(field, '%m/%d/%y')))
-            if row_nb == 1 and col_nb == time_col:
-                nb_cases['World'] = numpy.zeros(len(times))
             if row_nb >= 1:
                 if col_nb >= time_col:
-                    nb_cases['World'][col_nb - time_col] += int(field)
                     nb_cases[country][col_nb - time_col] += int(field)
 
+countries = list(nb_cases.keys())
+countries.sort()
+print('Countries: ', countries)
+
+nb_cases['World'] = sum(nb_cases.values())
+
 ######################################################################
 
 fig = plt.figure()
 ax.set_yscale('log')
 
 myFmt = mdates.DateFormatter('%b %d')
+
 ax.xaxis.set_major_formatter(myFmt)
 dates = mdates.epoch2num(times)
 
-print('Countries:')
-print(nb_cases.keys())
-
 for key, color, label in [
         ('World', 'blue', 'World'),
         ('Switzerland', 'red', 'Switzerland'),
 ax.legend(frameon = False)
 
 plt.show()
+
 fig.savefig('covid19.png')
 
 ######################################################################