Spaces:
Sleeping
Sleeping
import pandas as pd | |
from datetime import datetime | |
from typing import Dict, Any, List | |
def create_comprehensive_csv_data(data_source: str, company_info: str, accounting_standards: str, | |
regulatory_frameworks: List[str], result: Dict[str, Any]) -> pd.DataFrame: | |
"""Create comprehensive CSV data with all analysis information""" | |
# Extract company information | |
company_parts = company_info.split(" in the ") | |
company_type = company_parts[0] if len(company_parts) > 0 else "N/A" | |
industry_sector = company_parts[1].split(", classified as")[0] if len(company_parts) > 1 else "N/A" | |
company_size = company_parts[1].split("classified as ")[1].split(", for")[0] if len(company_parts) > 1 else "N/A" | |
financial_year = company_parts[1].split("for ")[-1] if len(company_parts) > 1 else "N/A" | |
# Create comprehensive data structure | |
comprehensive_data = [] | |
# 1. Basic Information | |
comprehensive_data.append({ | |
'Category': 'Basic Information', | |
'Field': 'Analysis Timestamp', | |
'Value': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), | |
'Details': 'Time when analysis was performed', | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
comprehensive_data.append({ | |
'Category': 'Basic Information', | |
'Field': 'Data Source', | |
'Value': data_source, | |
'Details': 'Source of financial data used for analysis', | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
comprehensive_data.append({ | |
'Category': 'Basic Information', | |
'Field': 'Company Type', | |
'Value': company_type, | |
'Details': 'Legal structure of the company', | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
comprehensive_data.append({ | |
'Category': 'Basic Information', | |
'Field': 'Industry Sector', | |
'Value': industry_sector, | |
'Details': 'Primary business sector', | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
comprehensive_data.append({ | |
'Category': 'Basic Information', | |
'Field': 'Company Size', | |
'Value': company_size, | |
'Details': 'Classification based on turnover and capital', | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
comprehensive_data.append({ | |
'Category': 'Basic Information', | |
'Field': 'Financial Year', | |
'Value': financial_year, | |
'Details': 'Reporting period under analysis', | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
comprehensive_data.append({ | |
'Category': 'Basic Information', | |
'Field': 'Accounting Standards', | |
'Value': accounting_standards, | |
'Details': 'Applicable accounting framework', | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
comprehensive_data.append({ | |
'Category': 'Basic Information', | |
'Field': 'Regulatory Frameworks', | |
'Value': ', '.join(regulatory_frameworks), | |
'Details': 'Applicable regulatory requirements', | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
# 2. AI Analysis Results (if available) | |
if isinstance(result, dict) and 'response' in result: | |
comprehensive_data.append({ | |
'Category': 'AI Analysis Results', | |
'Field': 'Full Analysis Response', | |
'Value': 'AI Generated Compliance Analysis', | |
'Details': result['response'][:1000] + '...' if len(result['response']) > 1000 else result['response'], | |
'Priority': '', | |
'Timeline': '', | |
'Regulation': '' | |
}) | |
return pd.DataFrame(comprehensive_data) |