Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file_path = 'InputFiles'
- #file_path = 'PDFInput'
- for file in os.listdir(file_path):
- if file.endswith('.pdf') or file.endswith('.PDF'):
- #print(file)
- pdf = pdfquery.PDFQuery(file_path+'/'+file)
- num_paginas = pdf.doc.catalog['Pages'].resolve()['Count']
- #print('Num: ', num_paginas)
- for pagina in range(0, num_paginas, 2):
- #print('Pagina: ', pagina)
- pdf.load(pagina)
- pdf.tree
- line = 0
- for etiqueta in pdf.tree.iter():
- line = line + 1
- #print(str(tag)+' '+str(tag.text))
- #print(str(line)+' '+str(etiqueta.text))
- if line == 59:
- num_serie = etiqueta.text.strip()
- if line == 61:
- fecha = etiqueta.text.strip()
- if line == 66:
- num_factura = etiqueta.text.strip()
- if line == 90:
- descripcion = etiqueta.text.strip()
- if line == 91:
- centro = etiqueta.text[8:12].strip()
- if line == 103:
- precio_unitario = etiqueta.text.strip()
- print(str(file)
- +' '+str(num_paginas)
- +' '+str(pagina+1)
- +' '+str(num_serie)
- +' '+str(fecha)
- +' '+str(num_factura)
- +' '+str(descripcion)
- +' '+str(centro)
- +' '+str(precio_unitario))
- print('FIN')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement