import os import datetime import sys import parse_pronos def write_infos_chevaux(pron_file,out_file) pronos_file = open(pron_file, 'r') infos_chevaux = open(out_file, 'w') for line in pronos_file: chevaux_result = parse_pronos.parse_infos_chevaux(line) chevaux = chevaux_result[0] nb_errors = nb_errors + chevaux_result[1] for cheval in chevaux : infos_chevaux.write(";".join(str(item) for item in cheval)) infos_chevaux.write('\n') pronos_file.close() infos_chevaux.close()
debut,\ fin,\ out_folder+'pronos_urls',\ out_folder+'results_url') except: print("Mauvais format de date !") sys.exit(1) pronos_file = open(out_folder+'pronos_urls', 'r') tosql.create_table('pronos_course') con=tosql.get_con() # Recuperer les pronos par tranches de 50 pour eviter deconnexion SQL et perte si plantage nb_line = 0 for line in pronos_file: pronos_course = parse_pronos.parse_infos_chevaux(line) tosql.tosql_insert(pronos_course[0],con.cursor(),'pronos_course') nb_line = nb_line+1 if nb_line > 49: con.commit() nb_line = 0 con.commit() if con: con.close() if pronos_file: pronos_file.close() print("OK !") # RECUPERER RESULTATS ET RAPPORTS