Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -303,7 +303,13 @@ def main():
|
|
303 |
else:
|
304 |
st.error("Error: Converted Excel file not found")
|
305 |
|
|
|
|
|
|
|
|
|
|
|
306 |
st.markdown("### STEP 2")
|
|
|
307 |
if not file_present:
|
308 |
st.markdown("#### Upload the Data Master file with Item Code mapping")
|
309 |
mapping_uploaded_file = st.file_uploader("Upload the Data Master file with Item Code mapping", type=["xlsx","ods"])
|
@@ -318,10 +324,37 @@ def main():
|
|
318 |
extracted_data_for_mapping = extracted_data_for_mapping[extracted_data_for_mapping['Item Code'].isna()]
|
319 |
unmapped_part_no = extracted_data_for_mapping['Customer Part no as per pdf'].nunique()
|
320 |
if unmapped_part_no>0:
|
321 |
-
st.markdown("
|
322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
else:
|
324 |
-
st.markdown("
|
325 |
mapping_uploaded_file = MAPPING_FILENAME
|
326 |
|
327 |
if mapping_uploaded_file is not None:
|
@@ -332,7 +365,7 @@ def main():
|
|
332 |
|
333 |
# Provide a link to download the final Excel file after mapping
|
334 |
st.markdown("### FINAL DOWNLOAD")
|
335 |
-
st.markdown("
|
336 |
|
337 |
final_excel_file = 'Final Data.xlsx'
|
338 |
mapped_data.to_excel(final_excel_file, index=False)
|
@@ -348,6 +381,9 @@ def main():
|
|
348 |
)
|
349 |
else:
|
350 |
st.error("Error: Converted Excel file not found")
|
|
|
|
|
|
|
351 |
|
352 |
if __name__ == "__main__":
|
353 |
main()
|
|
|
303 |
else:
|
304 |
st.error("Error: Converted Excel file not found")
|
305 |
|
306 |
+
st.markdown("##### Click the button below if you want to upload a new mapping file")
|
307 |
+
if st.button("Delete Mapping file in Cloud", key="delete"):
|
308 |
+
delete_master_file()
|
309 |
+
file_present = pull_mapping_file_from_drive()
|
310 |
+
|
311 |
st.markdown("### STEP 2")
|
312 |
+
mapping_uploaded_file = None
|
313 |
if not file_present:
|
314 |
st.markdown("#### Upload the Data Master file with Item Code mapping")
|
315 |
mapping_uploaded_file = st.file_uploader("Upload the Data Master file with Item Code mapping", type=["xlsx","ods"])
|
|
|
324 |
extracted_data_for_mapping = extracted_data_for_mapping[extracted_data_for_mapping['Item Code'].isna()]
|
325 |
unmapped_part_no = extracted_data_for_mapping['Customer Part no as per pdf'].nunique()
|
326 |
if unmapped_part_no>0:
|
327 |
+
st.markdown("There are {} Part No. with No ItemCode present. Upload a new file after mapping them".format(unmapped_part_no))
|
328 |
+
st.markdown("Do you want to skip this or Upload a new Mapping File")
|
329 |
+
|
330 |
+
if 'button_pressed' not in st.session_state:
|
331 |
+
st.session_state.button_pressed = None
|
332 |
+
|
333 |
+
# placeholder = st.empty() # Create a placeholder
|
334 |
+
|
335 |
+
if st.session_state.button_pressed is None:
|
336 |
+
if st.button("Skip"):
|
337 |
+
st.session_state.button_pressed = "Skip"
|
338 |
+
# placeholder.empty() # Clear the placeholder content
|
339 |
+
|
340 |
+
if st.button("Upload a new Master Mapping"):
|
341 |
+
st.session_state.button_pressed = "Upload a new Master Mapping"
|
342 |
+
# placeholder.empty() # Clear the placeholder content
|
343 |
+
|
344 |
+
|
345 |
+
if st.session_state.button_pressed is not None:
|
346 |
+
# Common block of code that uses the variable
|
347 |
+
|
348 |
+
if st.session_state.button_pressed == "Skip":
|
349 |
+
mapping_uploaded_file = MAPPING_FILENAME
|
350 |
+
# Add your code that runs when Yes is pressed
|
351 |
+
|
352 |
+
elif st.session_state.button_pressed == "Upload a new Master Mapping":
|
353 |
+
mapping_uploaded_file = st.file_uploader("Upload the Data Master file with Item Code mapping", type=["xlsx","ods"])
|
354 |
+
# Add your code that runs when No is pressed
|
355 |
+
|
356 |
else:
|
357 |
+
st.markdown("All Part No. are mapped with ItemCode so using the Mapping file available in Google Drive")
|
358 |
mapping_uploaded_file = MAPPING_FILENAME
|
359 |
|
360 |
if mapping_uploaded_file is not None:
|
|
|
365 |
|
366 |
# Provide a link to download the final Excel file after mapping
|
367 |
st.markdown("### FINAL DOWNLOAD")
|
368 |
+
st.markdown("Final Excel File After Mapping")
|
369 |
|
370 |
final_excel_file = 'Final Data.xlsx'
|
371 |
mapped_data.to_excel(final_excel_file, index=False)
|
|
|
381 |
)
|
382 |
else:
|
383 |
st.error("Error: Converted Excel file not found")
|
384 |
+
|
385 |
+
st.session_state.button_pressed = None
|
386 |
+
|
387 |
|
388 |
if __name__ == "__main__":
|
389 |
main()
|