comparison facturation.py @ 5:10333ba7d53a draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/facturation_ibps commit 2f48d2b0d72cdd8f521ff4dee38590e91afc4bf8
author artbio
date Wed, 09 Jan 2019 13:16:44 -0500
parents ddc7b8073704
children b8460b9f4253
comparison
equal deleted inserted replaced
4:ddc7b8073704 5:10333ba7d53a
13 the_parser = argparse.ArgumentParser() 13 the_parser = argparse.ArgumentParser()
14 the_parser.add_argument('--input', '-i', action='store', type=str, 14 the_parser.add_argument('--input', '-i', action='store', type=str,
15 help="input html code to convert to xlsx") 15 help="input html code to convert to xlsx")
16 the_parser.add_argument('--output', '-o', action='store', type=str, 16 the_parser.add_argument('--output', '-o', action='store', type=str,
17 help='xlsx converted file') 17 help='xlsx converted file')
18 the_parser.add_argument('--template', '-t', action='store', type=str,
19 help='xlsx template file')
18 args = the_parser.parse_args() 20 args = the_parser.parse_args()
19 return args 21 return args
20 22
21 23
22 def main(input_file, output_file): 24 def main(template, input_file, output_file):
23 """Script de parsing des fichiers de facturation de l'IBPS""" 25 """Script de parsing des fichiers de facturation de l'IBPS"""
24 26
25 # ouverture fichier input 27 # ouverture fichier input
26 with open(input_file, 'r') as file_object: 28 with open(input_file, 'r') as file_object:
27 facture_html = file_object.read() 29 facture_html = file_object.read()
62 elements[u'nombre(s)'] = pd.to_numeric(elements[u'nombre(s)']) 64 elements[u'nombre(s)'] = pd.to_numeric(elements[u'nombre(s)'])
63 elements[cout_col] = pd.to_numeric(elements[cout_col]) 65 elements[cout_col] = pd.to_numeric(elements[cout_col])
64 66
65 # ouverture fichier output 67 # ouverture fichier output
66 facture_output = openpyxl.load_workbook( 68 facture_output = openpyxl.load_workbook(
67 'template_facture.xlsx', data_only=False, keep_vba=False) 69 template, data_only=False, keep_vba=False)
68 ws = facture_output.worksheets[0] 70 ws = facture_output.worksheets[0]
69 71
70 # rajout de l'image de SU qui ne survit pas à la conversion 72 # rajout de l'image de SU qui ne survit pas à la conversion
71 img = openpyxl.drawing.image.Image('template_SU.jpg') 73 img = openpyxl.drawing.image.Image('template_SU.jpg')
72 img.anchor = "A1" 74 img.anchor = "A1"
103 return 105 return
104 106
105 107
106 if __name__ == '__main__': 108 if __name__ == '__main__':
107 args = Parser() 109 args = Parser()
108 main(args.input, args.output) 110 main(args.template, args.input, args.output)