This func is used to reading txt file :param origin: :param path: path where file stored :param mode: :type path: str :return: string lines in file in a list :rtype: list
(path, mode='utf-8-sig', origin=False)
| 12 | |
| 13 | |
| 14 | def load_txt_data(path, mode='utf-8-sig', origin=False): |
| 15 | """ |
| 16 | This func is used to reading txt file |
| 17 | :param origin: |
| 18 | :param path: path where file stored |
| 19 | :param mode: |
| 20 | :type path: str |
| 21 | :return: string lines in file in a list |
| 22 | :rtype: list |
| 23 | """ |
| 24 | if type(path) != str: |
| 25 | raise TypeError |
| 26 | res = [] |
| 27 | |
| 28 | file = open(path, 'rb') |
| 29 | lines = file.read().decode(mode, 'ignore') |
| 30 | for line in lines.split('\n'): |
| 31 | line = line.strip() |
| 32 | if origin: |
| 33 | res.append(line) |
| 34 | else: |
| 35 | if line: |
| 36 | res.append(line) |
| 37 | file.close() |
| 38 | return res |
| 39 | |
| 40 | |
| 41 | def load_excel_data(path): |
no test coverage detected