Spaces:
Sleeping
Sleeping
Commit
Β·
b4c9157
1
Parent(s):
4a1a4ce
Add commented code for CSV file cleaning
Browse files
pages/14_π_Table_Data_Visualization.py
CHANGED
@@ -28,4 +28,85 @@ def app():
|
|
28 |
# Show the plot
|
29 |
st.pyplot(fig)
|
30 |
|
31 |
-
app()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
# Show the plot
|
29 |
st.pyplot(fig)
|
30 |
|
31 |
+
app()
|
32 |
+
|
33 |
+
# import io
|
34 |
+
# import base64
|
35 |
+
|
36 |
+
# st.set_page_config(page_title="Data Cleaning Tool")
|
37 |
+
|
38 |
+
# hide_streamlit_style = """
|
39 |
+
# <style>
|
40 |
+
# #MainMenu {visibility: hidden;}
|
41 |
+
# footer {visibility: hidden;}
|
42 |
+
# </style>
|
43 |
+
# """
|
44 |
+
# st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
45 |
+
|
46 |
+
# st.title("CSV Data Cleaning Tool")
|
47 |
+
|
48 |
+
# st.markdown("Upload one or multiple CSV files to preprocess and clean your files quickly and stress free.")
|
49 |
+
|
50 |
+
# uploaded_files = st.file_uploader("Choose CSV files", type="csv", accept_multiple_files=True)
|
51 |
+
|
52 |
+
# dataframes = []
|
53 |
+
|
54 |
+
# if uploaded_files:
|
55 |
+
# for file in uploaded_files:
|
56 |
+
# file.seek(0)
|
57 |
+
# df = pd.read_csv(file)
|
58 |
+
# dataframes.append(df)
|
59 |
+
|
60 |
+
# if len(dataframes) > 1:
|
61 |
+
# merge = st.checkbox("Merge uploaded CSV files")
|
62 |
+
|
63 |
+
# if merge:
|
64 |
+
# # Merge options
|
65 |
+
# keep_first_header_only = st.selectbox("Keep only the header (first row) of the first file", ["Yes", "No"])
|
66 |
+
# remove_duplicate_rows = st.selectbox("Remove duplicate rows", ["No", "Yes"])
|
67 |
+
# remove_empty_rows = st.selectbox("Remove empty rows", ["Yes", "No"])
|
68 |
+
# end_line = st.selectbox("End line", ["\\n", "\\r\\n"])
|
69 |
+
|
70 |
+
# try:
|
71 |
+
# if keep_first_header_only == "Yes":
|
72 |
+
# for i, df in enumerate(dataframes[1:]):
|
73 |
+
# df.columns = dataframes[0].columns.intersection(df.columns)
|
74 |
+
# dataframes[i+1] = df
|
75 |
+
|
76 |
+
# merged_df = pd.concat(dataframes, ignore_index=True, join='outer')
|
77 |
+
|
78 |
+
# if remove_duplicate_rows == "Yes":
|
79 |
+
# merged_df.drop_duplicates(inplace=True)
|
80 |
+
|
81 |
+
# if remove_empty_rows == "Yes":
|
82 |
+
# merged_df.dropna(how="all", inplace=True)
|
83 |
+
|
84 |
+
# dataframes = [merged_df]
|
85 |
+
|
86 |
+
# except ValueError as e:
|
87 |
+
# st.error("Please make sure columns match in all files. If you don't want them to match, select 'No' in the first option.")
|
88 |
+
# st.stop()
|
89 |
+
|
90 |
+
# # Show or hide DataFrames
|
91 |
+
# show_dataframes = st.checkbox("Show DataFrames", value=True)
|
92 |
+
|
93 |
+
# if show_dataframes:
|
94 |
+
# for i, df in enumerate(dataframes):
|
95 |
+
# st.write(f"DataFrame {i + 1}")
|
96 |
+
# st.dataframe(df)
|
97 |
+
|
98 |
+
# if st.button("Download cleaned data"):
|
99 |
+
# for i, df in enumerate(dataframes):
|
100 |
+
# csv = df.to_csv(index=False)
|
101 |
+
# b64 = base64.b64encode(csv.encode()).decode()
|
102 |
+
# href = f'<a href="data:file/csv;base64,{b64}" download="cleaned_data_{i + 1}.csv">Download cleaned_data_{i + 1}.csv</a>'
|
103 |
+
# st.markdown(href, unsafe_allow_html=True)
|
104 |
+
# else:
|
105 |
+
# st.warning("Please upload CSV file(s).")
|
106 |
+
# st.stop()
|
107 |
+
|
108 |
+
# st.markdown("")
|
109 |
+
# st.markdown("---")
|
110 |
+
# st.markdown("")
|
111 |
+
# st.markdown("<p style='text-align: center'><a href='https://github.com/Kaludii'>Github</a> | <a href='https://huggingface.co/Kaludi'>HuggingFace</a></p>", unsafe_allow_html=True)
|
112 |
+
|