bacngv commited on
Commit
04d51d9
·
verified ·
1 Parent(s): 504dbd0

Update io_utils.py

Browse files
Files changed (1) hide show
  1. io_utils.py +4 -6
io_utils.py CHANGED
@@ -5,11 +5,9 @@ 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
- 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
 
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 # Trả về đường dẫn file .txt
9
 
10
+ def save_to_csv(data, csv_filename):
 
 
11
  df = pd.DataFrame(data)
12
+ df.to_csv(csv_filename, index=False)
13
+ return csv_filename # Trả về đường dẫn file CSV