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
DataFrame
object ifreturn_pandas_df
isTrue
, 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.DataFrame
orDict[str, List[Any]]]
Usage:
>>> import EzPyZ as ez >>> data = ez.tools.read_file("bmi_data.csv")
is_excel()¶
-
EzPyZ.tools.
is_excel
(filename)¶ Returns
True
if the file provided infilename
is a valid Excel file, andFalse
otherwise.- Parameters
filename (
str
) – The qualified name of the file to be checked.- Returns
Boolean. Whether
filename
is a valid Excel file.- Return type
bool
Usage:
>>> import EzPyZ as ez >>> ez.tools.read_files.is_excel("bmi_data.xlsx") True