Untitled
unknown
plain_text
a year ago
940 B
6
Indexable
def process_file(file_path): data = pd.read_excel(file_path, header=3) new_headers = [] base_year = 2023 # Установите начальный год данных for col in data.columns: # Используйте регулярное выражение для извлечения названия периода и суффикса match = re.match(r'([а-яА-ЯёЁ\s-]+)(?:\.(\d+))?', col.strip()) if match: period_name, suffix = match.groups() period_name = period_name.strip() year_offset = int(suffix) - 1 if suffix else 0 current_year = base_year + year_offset if period_name.lower() in period_dict: new_headers.append(period_to_date(period_name, str(current_year))) else: new_headers.append(col) else: new_headers.append(col) data.columns = new_headers
Editor is loading...
Leave a Comment