Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,28 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import csv
|
|
|
|
| 4 |
|
| 5 |
# Load the CSV data
|
| 6 |
@st.cache_data
|
| 7 |
def load_data(file_path):
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Paginate function
|
| 12 |
def paginate_data(df, page_number, page_size):
|
|
@@ -54,3 +70,4 @@ def main():
|
|
| 54 |
if __name__ == "__main__":
|
| 55 |
main()
|
| 56 |
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import csv
|
| 4 |
+
import re
|
| 5 |
|
| 6 |
# Load the CSV data
|
| 7 |
@st.cache_data
|
| 8 |
def load_data(file_path):
|
| 9 |
+
def custom_csv_parser(file_path):
|
| 10 |
+
with open(file_path, 'r', newline='', encoding='utf-8') as csvfile:
|
| 11 |
+
reader = csv.reader(csvfile, delimiter=',', quotechar='"')
|
| 12 |
+
parsed_data = []
|
| 13 |
+
for row in reader:
|
| 14 |
+
parsed_row = []
|
| 15 |
+
for field in row:
|
| 16 |
+
if field.startswith('"') and field.endswith('"'):
|
| 17 |
+
parsed_row.append(field.strip('"'))
|
| 18 |
+
elif field.startswith('[') and field.endswith(']'):
|
| 19 |
+
parsed_row.append(field)
|
| 20 |
+
else:
|
| 21 |
+
parsed_row.append(field)
|
| 22 |
+
parsed_data.append(parsed_row)
|
| 23 |
+
return pd.DataFrame(parsed_data[1:], columns=parsed_data[0])
|
| 24 |
+
|
| 25 |
+
return custom_csv_parser(file_path)
|
| 26 |
|
| 27 |
# Paginate function
|
| 28 |
def paginate_data(df, page_number, page_size):
|
|
|
|
| 70 |
if __name__ == "__main__":
|
| 71 |
main()
|
| 72 |
|
| 73 |
+
|