Data in a table form can be transformed into numerous different formats using the class pyMez.Code.DataHandlers.GraphModels.TableGraph. The abstract data model is a table with column names.
Excel File |
Csv File |
Hdf File |
Html File |
Json File |
Matlab File |
Open Office File |
XML File |
from pyMez.Code.DataHandlers.GraphModels import *
# create the graph
graph=TableGraph()
# now we have access to the folowing data formats
graph.node_names
# to visualize the graph use the show method
graph.show()
# if we want to open an ascii data table or subclass we open the schema and then open the file
schema=read_schema(os.path.join(os.getcwd(),"./TableGraph_Files/Line_4909_WR15_Wave_Parameters_20180313_003.schema"))
ascii_table=AsciiDataTable(os.path.join(os.getcwd(),"./TableGraph_Files/Line_4909_WR15_Wave_Parameters_20180313_003.w2p"),
**schema)
graph.set_state(node_name="AsciiDataTable",node_data=ascii_table)
# now if you want a pandas data frame just move to that node
graph.move_to_node("DataFrame")
#now dataframe is just
pandas_dataframe=graph.data
pandas_dataframe[0:10]
# if we want to transform to json string
graph.move_to_node("JsonString")
json=graph.data
# if we would like to transform it to all possible data types -the xslx and ods require a confirmation
# first change the working directory and now all files will be put in the folder
os.chdir("./TableGraph_Files")
visit_all_nodes(graph)