コード例 #1
0
ファイル: ReadersWriters.py プロジェクト: minghao2016/T-CARER
 def exists_text(path: str, title: str, ext: str) -> bool:
     """Check if the text file exists.
     :param path: the directory path of the text file.
     :param title: the file name of the text file.
     :param ext: he extension of the text file.
     :return: indicates if the file exists.
     """
     reader = TextFile()
     reader.set(path, title, ext)
     return reader.exists()
コード例 #2
0
ファイル: ReadersWriters.py プロジェクト: minghao2016/T-CARER
 def load_text(path: str, title: str, ext: str, skip: int) -> List:
     """Read the text file into dataframe or list.
     :param path: the directory path of the text file.
     :param title: the file name of the text file.
     :param ext: the extension of the text file.
     :param skip: lines to skip before reading or writing.
     """
     reader = TextFile()
     reader.set(path, title, ext)
     return reader.read(skip)
コード例 #3
0
ファイル: ReadersWriters.py プロジェクト: minghao2016/T-CARER
 def size_text(path: str, title: str, ext: str) -> int:
     """Check number of lines in the text file.
     :param path: the directory path of the text file.
     :param title: the title of the text file.
     :param ext: the extension of the text file.
     :return: number of lines in the text file.
     """
     reader = TextFile()
     reader.set(path, title, ext)
     return reader.size()
コード例 #4
0
ファイル: ReadersWriters.py プロジェクト: minghao2016/T-CARER
 def reset_text(path: str, title: str, ext: str = "log"):
     """Reset the text file reader/writer.
     :param path: the directory path of the text file.
     :param title: the file name of the text file.
     :param ext: the extension of the text file.
     """
     reader = TextFile()
     reader.set(path, title, ext)
     reader.reset()
コード例 #5
0
ファイル: ReadersWriters.py プロジェクト: minghao2016/T-CARER
 def save_text(path: str,
               title: str,
               data: Callable[[List, Dict, PandasDataFrame], None],
               append=False,
               ext="log"):
     """Append to text file using dataframe, dictionary or list.
     :param path: the directory path of the text file.
     :param title: the file name of the text file.
     :param data: the data to write.
     :param append: indicates if data to be appended to an existing file.
     :param ext: the extension of the CSV file.
     """
     writer = TextFile()
     writer.set(path, title, ext)
     if append is False:
         writer.reset()
     writer.append(data)