eshan6704 commited on
Commit
eb10597
·
verified ·
1 Parent(s): 5f3429c

Update bhavcopy_html.py

Browse files
Files changed (1) hide show
  1. bhavcopy_html.py +6 -4
bhavcopy_html.py CHANGED
@@ -1,8 +1,9 @@
1
  import datetime
 
2
 
3
  def fetch_bhavcopy_html(date_str):
4
  """
5
- Use existing nse_bhavcopy function to fetch Bhavcopy and return HTML.
6
  """
7
  # Validate date format
8
  try:
@@ -10,10 +11,11 @@ def fetch_bhavcopy_html(date_str):
10
  except ValueError:
11
  return "<h3>Invalid date format. Please use DD-MM-YYYY.</h3>"
12
 
13
- # Fetch data using your existing function
14
  try:
15
  df = nse_bhavcopy(date_str)
16
- # Convert to HTML and wrap scrollable
17
- return wrap(df)
 
18
  except Exception:
19
  return f"<h3>No Bhavcopy found for {date_str}. Please check the date.</h3>"
 
1
  import datetime
2
+ from nsepython import *
3
 
4
  def fetch_bhavcopy_html(date_str):
5
  """
6
+ Use existing nse_bhavcopy function to fetch Bhavcopy and return HTML directly.
7
  """
8
  # Validate date format
9
  try:
 
11
  except ValueError:
12
  return "<h3>Invalid date format. Please use DD-MM-YYYY.</h3>"
13
 
14
+ # Fetch data using existing function
15
  try:
16
  df = nse_bhavcopy(date_str)
17
+ # Convert DataFrame to HTML directly
18
+ html = df.to_html(index=False, escape=False)
19
+ return html
20
  except Exception:
21
  return f"<h3>No Bhavcopy found for {date_str}. Please check the date.</h3>"