MCPcopy Index your code
hub / github.com/Turing-Project/WriteGPT / load_txt_data

Function load_txt_data

LanguageNetwork/BERT/utils/dataio.py:14–38  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

12
13
14def 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
41def load_excel_data(path):

Callers 8

load_predict_gen_vectorFunction · 0.90
merge_filesFunction · 0.90
split_docFunction · 0.90
split_doc2Function · 0.90
revers_indexFunction · 0.90
filter_dataFunction · 0.90
tokenize_format_linesFunction · 0.90

Calls 2

closeMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected