1234567891011121314151617181920212223242526272829 |
- import os
- import sys
- sys.path.append(os.path.dirname(__file__) + "/../")
- import logging
- import traceback
- from format_convert import get_memory_info
- from format_convert.convert_need_interface import from_office_interface
- from format_convert.convert_xlsx import xlsx2text
- from format_convert.utils import judge_error_code
- @get_memory_info.memory_decorator
- def xls2text(path, unique_type_dir):
- logging.info("into xls2text")
- try:
- # 调用libreoffice格式转换
- file_path = from_office_interface(path, unique_type_dir, 'xlsx')
- if judge_error_code(file_path):
- return file_path
- text = xlsx2text(file_path, unique_type_dir)
- if judge_error_code(text):
- return text
- return text
- except Exception as e:
- logging.info("xls2text error!")
- print("xls2text", traceback.print_exc())
- return [-1]
|