Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,10 +31,11 @@ def scrape_books(pages=1):
|
|
| 31 |
df = pd.DataFrame(all_books)
|
| 32 |
return df
|
| 33 |
|
| 34 |
-
# Mask titles
|
| 35 |
-
def
|
| 36 |
-
|
| 37 |
-
|
|
|
|
| 38 |
|
| 39 |
# Encrypt CSV
|
| 40 |
def encrypt_csv(df):
|
|
@@ -51,7 +52,7 @@ def app_interface(pages, security_option):
|
|
| 51 |
df = scrape_books(pages)
|
| 52 |
|
| 53 |
if security_option == "Mask Titles":
|
| 54 |
-
df =
|
| 55 |
file_path = "books_masked.csv"
|
| 56 |
df.to_csv(file_path, index=False)
|
| 57 |
return df, file_path, "Masked CSV ready to download."
|
|
|
|
| 31 |
df = pd.DataFrame(all_books)
|
| 32 |
return df
|
| 33 |
|
| 34 |
+
# Mask titles (original title removed)
|
| 35 |
+
def mask_titles_only(df):
|
| 36 |
+
df_masked = df.copy()
|
| 37 |
+
df_masked["Title"] = df_masked["Title"].apply(lambda x: x[0] + "***" if x != "N/A" else x)
|
| 38 |
+
return df_masked
|
| 39 |
|
| 40 |
# Encrypt CSV
|
| 41 |
def encrypt_csv(df):
|
|
|
|
| 52 |
df = scrape_books(pages)
|
| 53 |
|
| 54 |
if security_option == "Mask Titles":
|
| 55 |
+
df = mask_titles_only(df)
|
| 56 |
file_path = "books_masked.csv"
|
| 57 |
df.to_csv(file_path, index=False)
|
| 58 |
return df, file_path, "Masked CSV ready to download."
|