-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
41 lines (34 loc) · 1.01 KB
/
utils.py
File metadata and controls
41 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Utility functions for SSL, NLTK downloads, and database operations
"""
import nltk
import ssl
import sqlite3
import pandas as pd
def setup_nltk():
"""Configure SSL and download required NLTK data"""
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
# Download required NLTK data
nltk.download('punkt', quiet=True)
nltk.download('punkt_tab', quiet=True)
def load_indicator_data(db_path: str, table_name: str = 'Indicator') -> pd.DataFrame:
"""
Load indicator data from SQLite database
Args:
db_path: Path to SQLite database
table_name: Name of the table to query
Returns:
DataFrame containing indicator data
"""
conn = sqlite3.connect(db_path)
try:
query = f"SELECT * FROM {table_name};"
df = pd.read_sql(query, conn)
return df
finally:
conn.close()