Icon

kn_​example_​python_​ods_​calc_​read_​write

Read and write ODS (Libre Office) calc sheets with Python and KNIME

Read and write ODS (Libre Office) calc sheets with Python and KNIME


# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_ods_calc_read_write/data/py_knime_ods.yml"# conda update -n py_knime_ods --all# conda env update --name py_knime_ods --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_ods_calc_read_write/data/py_knime_ods.yml" --prune# conda env update --name py_knime_ods --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_ods_calc_read_write/data/py_knime_ods.yml"# conda update -n base conda# conda install -c conda-forge aiohttp # file: py_knime_ods.yml with some modifications# edit FEB-2023 - new meta package https://anaconda.org/knime# THX Carsten Haubold (https://hub.knime.com/carstenhaubold) for thisname: py_knime_ods # Name of the created environmentchannels: # Repositories to search for packages# - defaults # edit: removed to just use conda-forge# - anaconda # edit: removed to just use conda-forge- conda-forge- knime # conda search knime-python-base -c knime --infodependencies: # List of packages that should be installed- python=3.9 # Python- knime-python-base # dependencies of KNIME - Python integration# - knime-python-scripting # to also build Python packages for KNIME- cairo # SVG support- pillow # Image inputs/outputs- matplotlib # Plotting- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- jpype1 # A Python to Java bridge- jupyter # Jupyter Notebook- odfpy # ODS Reader- pyexcel-ods3 # conda install -c conda-forge pyexcel-ods3 - pip # Python installer- pip: # install additional packages via pip# - vtreat # additional packages that would to be available in conda-forge conda install -c conda-forge odfpyconda install -c conda-forge pyexcel-ods3 Read and write ODS (Libre Office) calc sheets with Python and KNIME import knime.scripting.io as knioimport pandas as pdvar_ods_file = knio.flow_variables['v_import_file']df = pd.read_excel(var_ods_file, sheet_name="cars", engine='odf')knio.output_tables[0] = knio.Table.from_pandas(df) KNIME and Python — Setting up and managing Conda environmentshttps://medium.com/p/2ac217792539 locate and create/data/ folderwith absolute pathsv_import_filewritetest_data.odstest_data.odstest_data.odstest_data.odsv_import_filereadtest_data.odsreadcars.odsPropagate Python environmentfor KNIME on MacOSX (Apple Scilicon)OR Windowswith Miniforge / Minicondaconfigure how to handle the environmentdefault = just check the names Collect LocalMetadata Java EditVariable (simple) Python Script Test Data Generator Column Filter Merge Variables Column Filter Java EditVariable (simple) Python Script Python Script Row Filter conda_environment_ods # conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_ods_calc_read_write/data/py_knime_ods.yml"# conda update -n py_knime_ods --all# conda env update --name py_knime_ods --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_ods_calc_read_write/data/py_knime_ods.yml" --prune# conda env update --name py_knime_ods --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_ods_calc_read_write/data/py_knime_ods.yml"# conda update -n base conda# conda install -c conda-forge aiohttp # file: py_knime_ods.yml with some modifications# edit FEB-2023 - new meta package https://anaconda.org/knime# THX Carsten Haubold (https://hub.knime.com/carstenhaubold) for thisname: py_knime_ods # Name of the created environmentchannels: # Repositories to search for packages# - defaults # edit: removed to just use conda-forge# - anaconda # edit: removed to just use conda-forge- conda-forge- knime # conda search knime-python-base -c knime --infodependencies: # List of packages that should be installed- python=3.9 # Python- knime-python-base # dependencies of KNIME - Python integration# - knime-python-scripting # to also build Python packages for KNIME- cairo # SVG support- pillow # Image inputs/outputs- matplotlib # Plotting- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- jpype1 # A Python to Java bridge- jupyter # Jupyter Notebook- odfpy # ODS Reader- pyexcel-ods3 # conda install -c conda-forge pyexcel-ods3 - pip # Python installer- pip: # install additional packages via pip# - vtreat # additional packages that would to be available in conda-forge conda install -c conda-forge odfpyconda install -c conda-forge pyexcel-ods3 Read and write ODS (Libre Office) calc sheets with Python and KNIME import knime.scripting.io as knioimport pandas as pdvar_ods_file = knio.flow_variables['v_import_file']df = pd.read_excel(var_ods_file, sheet_name="cars", engine='odf')knio.output_tables[0] = knio.Table.from_pandas(df) KNIME and Python — Setting up and managing Conda environmentshttps://medium.com/p/2ac217792539 locate and create/data/ folderwith absolute pathsv_import_filewritetest_data.odstest_data.odstest_data.odstest_data.odsv_import_filereadtest_data.odsreadcars.odsPropagate Python environmentfor KNIME on MacOSX (Apple Scilicon)OR Windowswith Miniforge / Minicondaconfigure how to handle the environmentdefault = just check the namesCollect LocalMetadata Java EditVariable (simple) Python Script Test Data Generator Column Filter Merge Variables Column Filter Java EditVariable (simple) Python Script Python Script Row Filter conda_environment_ods

Nodes

Extensions

Links