import os import pandas as pd def save_remaining_text_to_txt(text, output_folder, page_num): txt_filename = os.path.join(output_folder, f'page_{page_num + 1}_remaining_text.txt') with open(txt_filename, "w", encoding="utf-8") as f: f.write(text) return txt_filename # Return the file path def save_to_csv(data, output_folder, csv_filename): os.makedirs(output_folder, exist_ok=True) # Ensure output folder exists csv_file_path = os.path.join(output_folder, csv_filename) df = pd.DataFrame(data) df.to_csv(csv_file_path, index=False) return csv_file_path # Return the CSV file path