date 1.2
This commit is contained in:
@@ -14,9 +14,7 @@ def process_sheet(df, real_arti:str, real_quantity:str, real_sum_1:str):
|
||||
df = df.iloc[2:].reset_index(drop=True)
|
||||
#Выборка
|
||||
df = df.iloc[:, [real_arti, real_quantity, real_sum_1]].copy().dropna()
|
||||
#df = df[[real_arti, real_quantity, real_sum_1]].copy().dropna() #copy and drop all NA values
|
||||
df = df[(df != 0).all(axis=1)] #drop all 0 values
|
||||
#df = df[[real_arti, real_quantity, real_sum_1]]
|
||||
df.rename(columns={"Unnamed: 1": 'arti', "Unnamed: 3": 'counts', "Unnamed: 4": 'price'}, inplace=True) #переименовываем для pydantic
|
||||
#Нормализация
|
||||
df['arti'] = df['arti'].astype(str).str.upper().str.extract(f'({settings.PATTERN})') #arti под regex
|
||||
@@ -26,7 +24,7 @@ def process_sheet(df, real_arti:str, real_quantity:str, real_sum_1:str):
|
||||
|
||||
#Группировка
|
||||
df = df.groupby('arti', as_index=False).agg({'counts': 'sum', 'price': 'sum'}) #groupping
|
||||
#df = processing(df) #vlookup for ref_keys
|
||||
df = processing(df) #vlookup for ref_keys
|
||||
validated_rows, errors = [], []
|
||||
for i, row in df.iterrows(): #проходит построчно по df, где i - индекс строки, row - данные строки
|
||||
try:
|
||||
|
||||
@@ -4,7 +4,7 @@ class ExcelInfo(BaseModel):
|
||||
arti:str = Field(..., min_length=5, max_length=12, description="arti of the clothes")
|
||||
counts:int = Field(..., gt=0, description="the quantity of the clothes")
|
||||
price:float = Field(..., gt=0, description="the price of the clothes")
|
||||
#ref_key:str = Field(..., description="reffering key from db")
|
||||
ref_key:str = Field(..., description="reffering key from db")
|
||||
class ExcelRealization(BaseModel):
|
||||
pass
|
||||
class ExcelReturning(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user