code: def savecsv(filename, datadict, mode="w"):
      
      if mode == "a" :
          header = False
      else:
          header = True
      with open(filename, mode) as f:
          _pd.DataFrame(datadict).to_csv(f, index=False, header=header)
docs: Save a dictionary of data to CSV.