read_files.py¶
read_file()¶
-
EzPyZ.tools.read_file(filename: str, return_pandas_df=False)¶ Reads the provided Excel or CSV data file. Returns a pandas
DataFrameobject ifreturn_pandas_dfisTrue, or a dictionary where the keys are column titles and the values are lists of associated values (in order) otherwise.- Parameters
filename (
str) – The qualified path to the data file to read.return_pandas_df – (optional) Boolean. Whether the data should be returned as a
pandas.DataFrame. Defaults toFalse.
- Returns
A formatted version of the data in
filename.- Return type
pandas.DataFrameorDict[str, List[Any]]]
Usage:
>>> import EzPyZ as ez >>> data = ez.tools.read_file("bmi_data.csv")
is_excel()¶
-
EzPyZ.tools.is_excel(filename)¶ Returns
Trueif the file provided infilenameis a valid Excel file, andFalseotherwise.- Parameters
filename (
str) – The qualified name of the file to be checked.- Returns
Boolean. Whether
filenameis a valid Excel file.- Return type
bool
Usage:
>>> import EzPyZ as ez >>> ez.tools.read_files.is_excel("bmi_data.xlsx") True