bacngv commited on
Commit
74dfafe
·
verified ·
1 Parent(s): 416f7a4

Update io_utils.py

Browse files
Files changed (1) hide show
  1. io_utils.py +6 -2
io_utils.py CHANGED
@@ -5,7 +5,11 @@ def save_remaining_text_to_txt(text, output_folder, page_num):
5
  txt_filename = os.path.join(output_folder, f'page_{page_num + 1}_remaining_text.txt')
6
  with open(txt_filename, "w", encoding="utf-8") as f:
7
  f.write(text)
 
8
 
9
- def save_to_csv(data, csv_filename):
 
 
10
  df = pd.DataFrame(data)
11
- df.to_csv(csv_filename, index=False)
 
 
5
  txt_filename = os.path.join(output_folder, f'page_{page_num + 1}_remaining_text.txt')
6
  with open(txt_filename, "w", encoding="utf-8") as f:
7
  f.write(text)
8
+ return txt_filename # Return the file path
9
 
10
+ def save_to_csv(data, output_folder, csv_filename):
11
+ os.makedirs(output_folder, exist_ok=True) # Ensure output folder exists
12
+ csv_file_path = os.path.join(output_folder, csv_filename)
13
  df = pd.DataFrame(data)
14
+ df.to_csv(csv_file_path, index=False)
15
+ return csv_file_path # Return the CSV file path