Spaces:
Build error
Build error
Upload app.py
Browse files7 unmodified lines8910111211121314151617181917 unmodified lines3738393840414243424344454647484950515253545556575846596061626364656667686970717273747576775051527879808182838485868767 unmodified lines15515615712815815916016115 unmodified lines1771781791501801811821831841551561571581591851861871887 unmodified linesimport requestsfrom io import BytesIOfrom openpyxl.styles import Border, Side,Alignment
department='Default 'sem='Default 'section='Default'def convert_pdf_to_excel(pdf_file):
rows = [] firstcolumn='' # Function to extract text from a PDF and process it into a tabular format17 unmodified lines sublists = []
i = 3 # Index to track position in the list
space=False while i < len(rows): # Check if the current value is "Department Name" if rows[i] == 'Department Name': # Skip next 6 values (including the current one) # print(rows[i]) # print(rows[i+1]) # print(rows[i+2]) # print(rows[i+3]) # print(rows[i+4]) # print(rows[i+5]) # print(rows[i+6]) # print(rows[i+7]) # print(rows[i+8]) # print(rows[i+9]) # break # Skip next 6 values (including the current one) print(rows[i]) department=rows[i+1] department=department.strip() section=rows[i+5] print("Dept is ",department) sem=rows[i+2] if(sem==' '): space=True sem=rows[i+3] print("sem is ",sem) section=rows[i+5] if(section=='Semester'): section=rows[i+6] print("section is ",section)
i += 7 if(space==True): i=i+1 print(department) print(sem) print(section) # print(department) # print(sem) # print(section) else:
# Extract a sublist of next 3 elements print('val',rows[i]) sublist = rows[i:i + 3] sublists.append(sublist) i += 3 # Move the index to the next set of 3 elements67 unmodified lines file_content = get_file_content_as_bytes(file_path) st.download_button( label='Download Excel mac', label='Download Excel File', data=file_content, file_name=file_path, mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'15 unmodified lines with open(file_path, "wb") as f: f.write(uploaded_file.getbuffer())
st.success(f'File "{file_name}" saved ') st.success(f'File "{file_name}" saved at "{file_path}"')
excel_file = convert_pdf_to_excel(file_name)
with open('./demo.css') as f: css = f.read()
st.markdown(f'<style>{css}</style>', unsafe_allow_html=True)
app.py+42-16