rodolphethinks1 commited on
Commit
0873404
·
verified ·
1 Parent(s): e8b3db5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -48,12 +48,16 @@ def update_dataframe(html_content, dataframe):
48
  # Parse the content and create a new row
49
  parsed_data = parse_content(html_content)
50
  new_row = pd.DataFrame([parsed_data])
51
-
 
52
  dataframe = pd.concat([dataframe, new_row], ignore_index=True)
53
 
54
  # Return the updated dataframe and the updated state
55
  return dataframe, dataframe
56
 
 
 
 
57
  with gr.Blocks() as interface:
58
  with gr.Column():
59
  gr.Markdown("## HTML Content Parser")
@@ -72,10 +76,13 @@ with gr.Blocks() as interface:
72
  label="Parsed Data",
73
  interactive=False,
74
  show_label=False, # Remove label if you don't want it to show
75
- row_count=5, # You can adjust the max number of rows to display
76
  wrap=True # Allow word wrap in the dataframe
77
  )
78
 
 
 
 
79
  # Define the button click event
80
  parse_button.click(
81
  fn=update_dataframe,
 
48
  # Parse the content and create a new row
49
  parsed_data = parse_content(html_content)
50
  new_row = pd.DataFrame([parsed_data])
51
+
52
+ # Concatenate the new row with the existing dataframe
53
  dataframe = pd.concat([dataframe, new_row], ignore_index=True)
54
 
55
  # Return the updated dataframe and the updated state
56
  return dataframe, dataframe
57
 
58
+ # Initialize an empty dataframe (initially with no rows)
59
+ initial_df = pd.DataFrame(columns=['Title', 'Date', 'Author', 'Views', 'Reviews', 'Content'])
60
+
61
  with gr.Blocks() as interface:
62
  with gr.Column():
63
  gr.Markdown("## HTML Content Parser")
 
76
  label="Parsed Data",
77
  interactive=False,
78
  show_label=False, # Remove label if you don't want it to show
79
+ row_count=5, # Limit the display to 5 rows
80
  wrap=True # Allow word wrap in the dataframe
81
  )
82
 
83
+ # Hidden state to store the dataframe
84
+ dataframe_state = gr.State(value=initial_df)
85
+
86
  # Define the button click event
87
  parse_button.click(
88
  fn=update_dataframe,