toto.inputs.txt¶
Read txt,csv file This import text file. The function uses the read_csv function from panda <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html>_. This class returns a Panda Dataframe with some extra attributes such as Latitude,Longitude,Units.
Parameters¶
- filename(files,) str or list_like
A list of filename to process.
- sepstr, default {_default_sep}
Delimiter to use. If sep is None, the C engine cannot automatically detect the separator, but the Python parsing engine can, meaning the latter will be used and automatically detect the separator by Python’s builtin sniffer tool,
csv.Sniffer. In addition, separators longer than 1 character and different from'\s+'will be interpreted as regular expressions and will also force the use of the Python parsing engine. Note that regex delimiters are prone to ignoring quoted data. Regex example:' '.- skiprowslist-like, int or callable, optional
Line numbers to skip (0-indexed) or number of lines to skip (int) at the start of the file. If callable, the callable function will be evaluated against the row indices, returning True if the row should be skipped and False otherwise. An example of a valid callable argument would be
lambda x: x in [0, 2].- skipfooterint, default 0
Number of lines at bottom of file to skip (Unsupported with engine=’c’).
- miss_valscalar, str, list-like, or dict, optional
Additional strings to recognize as NA/NaN. If dict passed, specific per-column NA values.
- colNamesLineint, default 1
Line number where the header are defined
- unitNamesLineint, default 1
Line number where the units are defined
- single_columnbool, default False
The time is represented in a single column
- customUnitstr, default ‘%d-%m-%Y %H:%M:%S’
String reprensenting the time format
- unitstr default ‘s’, can be ‘auto’,’custom’,’matlab’ or ‘s’ and ‘D’
unit of the single column time. Only matter if single_column is True
- time_col_name: dict, default {‘Year’:’year’,’Month’:’month’,’Day’:’day’,’Hour’:’hour’,’Min’:’Minute’,’Sec’:’Second’}
Dictonary for renaming the each column, so Panda can interprate the time. Only matter if single_column is False
- colNamesList, default []
List of column names to use.
- unitNamesList, default []
List of unit to use.
Notes¶
Whe openning the TOTOVIEW gui this function will be called with totoview.inputs.txtGUI
Examples¶
>>> from toto.inputs.txt import TXTfile
>>> tx=TXTfile([filename],colNamesLine=1,miss_val='NaN', sep=',',skiprows=1,unit='custom',time_col_name='time',unitNamesLine=0, single_column=True,customUnit='%d/%m/%Y %H:%M')
>>> tx.reads()
>>> tx.read_time()
>>> df=tx._toDataFrame()
- class toto.inputs.txt.TXTfile(filename, sep='\t', colNames=[], unitNames=[], miss_val='NaN', colNamesLine=1, skiprows=1, unitNamesLine=0, skipfooter=0, single_column=False, unit='s', customUnit='%d-%m-%Y %H:%M:%S', time_col_name={'Day': 'day', 'Hour': 'hour', 'Min': 'Minute', 'Month': 'month', 'Sec': 'Second', 'Year': 'year'})[source]¶
Bases:
object