MCPcopy
hub / github.com/Turing-Project/WriteGPT / save_txt_file

Function save_txt_file

LanguageNetwork/BERT/utils/dataio.py:64–87  ·  view source on GitHub ↗

This func is used to saving data to txt file support data type: list: Fully support dict: Only save dict key str: will save single char to each line tuple: Fully support set: Fully support :param data: data :param path: path to save :type path: str :param

(data, path, end='\n')

Source from the content-addressed store, hash-verified

62
63
64def save_txt_file(data, path, end='\n'):
65 """
66 This func is used to saving data to txt file
67 support data type:
68 list: Fully support
69 dict: Only save dict key
70 str: will save single char to each line
71 tuple: Fully support
72 set: Fully support
73 :param data: data
74 :param path: path to save
75 :type path: str
76 :param end:
77 :type end: str
78 :return: None
79 """
80 if type(data) not in [list, dict, str, tuple, set] or type(path) != str:
81 raise TypeError
82
83 remove_old_file(path)
84
85 with open(path, 'a', encoding='utf-8') as f:
86 for item in data:
87 f.write(str(item) + end)
88
89
90def save_variable(variable, path):

Callers 8

merge_filesFunction · 0.90
split_docFunction · 0.90
split_doc2Function · 0.90
revers_indexFunction · 0.90
filter_dataFunction · 0.90
testMethod · 0.90
predictMethod · 0.90

Calls 2

remove_old_fileFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected