Feat: better extraction of lot

This commit is contained in:
Bertrand Benjamin 2023-06-27 10:23:02 +02:00
parent 18c8282f63
commit ceebfb0a38
1 changed files with 8 additions and 8 deletions

View File

@ -1,3 +1,5 @@
import re
import numpy as np
import pandas as pd
@ -13,15 +15,13 @@ def is_it(page_text):
return False
def get_lot(x):
def get_lot(txt):
"""Return lot number from "RECAPITULATIF DES OPERATIONS" """
if x[:2].isdigit():
return x[:2]
if x[:1].isdigit():
return "0" + x[:1]
if x[:2] == "PC":
return "PC"
return ""
regex = r"[BSM](\d+)\s-"
result = re.findall(regex, txt)
if result:
return "{:02d}".format(int(result[0]))
return "*"
def keep_row(row):