hardik27 commited on
Commit
5161fe6
·
verified ·
1 Parent(s): 0dda2ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -96,7 +96,10 @@ def convert_pdf_to_excel(pdf_file):
96
 
97
  if 'Part Name' in data[index].strip():
98
  each_table_data.append(data[index+1])
99
-
 
 
 
100
  if data[index].strip() == 'ADJ':
101
  row_start_index = index + 1
102
 
@@ -113,13 +116,13 @@ def convert_pdf_to_excel(pdf_file):
113
  whole_data.append(each_table_data)
114
 
115
  whole_data = pd.DataFrame(whole_data)
116
- whole_data.columns = ["Part No.","Part Color Code","Part Name",'Date Qty']
117
  extracted_file = "Data Extracted.xlsx"
118
  data_for_mapping = "Data Mapping.xlsx"
119
 
120
  extracted_data_for_mapping = whole_data.drop('Date Qty',axis=1)
121
- extracted_data_for_mapping = extracted_data_for_mapping.drop_duplicates(subset=["Part No.","Part Color Code","Part Name"])
122
- extracted_data_for_mapping.columns = ['Customer Part no as per pdf','Customer Part color as per pdf','Customer Part name as per pdf']
123
  extracted_data_for_mapping['Item Code'] = ""
124
 
125
  whole_data.to_excel(extracted_file, index=False)
@@ -140,7 +143,7 @@ def map_data_to_template(excel_file, mapping_file):
140
  extracted_data[['SchDate','Qty']]= pd.DataFrame(extracted_data['Date Qty'].to_list(), index= extracted_data.index)
141
  extracted_data = extracted_data.drop('Date Qty',axis=1)
142
  extracted_data = extracted_data[~extracted_data['SchDate'].isna()]
143
- mapped_data = extracted_data.merge(mapping_data, on =['Part No.'],how='outer')[['Item Code','SchDate','Qty']]
144
  mapped_data = mapped_data[~mapped_data["SchDate"].isna()]
145
  mapped_data = mapped_data[~mapped_data["SchDate"].str.strip().isin(["",None])]
146
  mapped_data['SOType'] = "R"
@@ -227,7 +230,7 @@ def main():
227
  if file_present:
228
  mapping_data_from_drive = pd.read_excel(MAPPING_FILENAME)
229
  extracted_data_for_mapping = pd.read_excel(data_for_mapping)
230
- extracted_data_for_mapping = extracted_data_for_mapping[['Customer Part no as per pdf','Customer Part name as per pdf','Customer Part color as per pdf']].merge(mapping_data_from_drive, on = ['Customer Part no as per pdf','Customer Part name as per pdf','Customer Part color as per pdf'], how='outer')
231
  extracted_data_for_mapping.to_excel(data_for_mapping,index=False)
232
 
233
  # Download link for the Excel file
 
96
 
97
  if 'Part Name' in data[index].strip():
98
  each_table_data.append(data[index+1])
99
+
100
+ if 'Inventory Category' in data[index].strip():
101
+ each_table_data.append(data[index+1].replace('Receive Type',""))
102
+
103
  if data[index].strip() == 'ADJ':
104
  row_start_index = index + 1
105
 
 
116
  whole_data.append(each_table_data)
117
 
118
  whole_data = pd.DataFrame(whole_data)
119
+ whole_data.columns = ["Part No.","Part Color Code","Part Name",'Inventory Category','Date Qty']
120
  extracted_file = "Data Extracted.xlsx"
121
  data_for_mapping = "Data Mapping.xlsx"
122
 
123
  extracted_data_for_mapping = whole_data.drop('Date Qty',axis=1)
124
+ extracted_data_for_mapping = extracted_data_for_mapping.drop_duplicates(subset=["Part No.","Part Color Code","Part Name","Inventory Category"])
125
+ extracted_data_for_mapping.columns = ['Customer Part no as per pdf','Customer Part color as per pdf','Customer Part name as per pdf',"Inventory Category"]
126
  extracted_data_for_mapping['Item Code'] = ""
127
 
128
  whole_data.to_excel(extracted_file, index=False)
 
143
  extracted_data[['SchDate','Qty']]= pd.DataFrame(extracted_data['Date Qty'].to_list(), index= extracted_data.index)
144
  extracted_data = extracted_data.drop('Date Qty',axis=1)
145
  extracted_data = extracted_data[~extracted_data['SchDate'].isna()]
146
+ mapped_data = extracted_data.merge(mapping_data, on =['Part No.'],how='outer')[['Item Code','SchDate','Qty','Inventory Category']]
147
  mapped_data = mapped_data[~mapped_data["SchDate"].isna()]
148
  mapped_data = mapped_data[~mapped_data["SchDate"].str.strip().isin(["",None])]
149
  mapped_data['SOType'] = "R"
 
230
  if file_present:
231
  mapping_data_from_drive = pd.read_excel(MAPPING_FILENAME)
232
  extracted_data_for_mapping = pd.read_excel(data_for_mapping)
233
+ extracted_data_for_mapping = extracted_data_for_mapping[['Customer Part no as per pdf','Customer Part name as per pdf','Customer Part color as per pdf',"Inventory Category"]].merge(mapping_data_from_drive, on = ['Customer Part no as per pdf','Customer Part name as per pdf','Customer Part color as per pdf'], how='outer')
234
  extracted_data_for_mapping.to_excel(data_for_mapping,index=False)
235
 
236
  # Download link for the Excel file