TabularDataUtil
Script for reading and accessing tabular data
Functions:
-
read_csv–read the data from the csv file
-
read_xml–Read partial data from xml file and return a DataFrame. Xml file should be those which can be converted into tabular data.
-
read_xlsx–read an Excel file
-
read_matrix–read a matrix
-
has_duplicates–check if data frame has duplicated column headers and return them if it has
-
concat–concatenate
-
eval_noex–Evaluate value from Table without throwing exceptions, only used to evaluate value that is string or None
read_csv
read_csv(csv_path: str) -> DataFrame
read the data from the csv file
Parameters:
-
csv_path(str) –path of the csv file
Returns:
-
DataFrame–data frame
read_xml
read_xml(xml_path: str, *args: list[Any]) -> Optional[DataFrame]
Read partial data from xml file and return a DataFrame. Xml file should be those which can be converted into tabular data.
Parameters:
-
xml_path(str) –xml file path
-
*args(list[Any], default:()) –string, the ElementTree tags, which serve later as column labels of data frame
Returns:
-
Optional[DataFrame]–data frame
read_xlsx
read_xlsx(xlsx_path: str, sheet: Union[int, str] = 0) -> DataFrame
read an Excel file
Parameters:
-
xlsx_path(str) –excel path
-
sheet(Union[int, str], default:0) –sheet index
Returns:
-
DataFrame–data frame
read_matrix
read_matrix(lists: List[List[Any]]) -> DataFrame
has_duplicates
has_duplicates(
data_frame: DataFrame, duplicates: List[Union[int, str]]
) -> bool
check if data frame has duplicated column headers and return them if it has
Parameters:
-
data_frame(DataFrame) –data frame
-
duplicates(List[Union[int, str]]) –duplicates
Returns:
-
bool–duplicated state
concat
eval_noex
Evaluate value from Table without throwing exceptions, only used to evaluate value that is string or None
Parameters:
-
value(Any) –new value
-
default(Any, default:None) –has a higher priority than value_type, when both default and value_type are given
-
value_type(Any, default:None) –string that indicates the value type
Returns:
-
Any–eval result