diff --git a/Daten_ohne_relationships.ipynb b/Daten_ohne_relationships.ipynb
new file mode 100644
index 0000000..9c60714
--- /dev/null
+++ b/Daten_ohne_relationships.ipynb
@@ -0,0 +1,1086 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "73e934a8-9027-4ad1-ad15-e68fba847768",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ },
+ "scrolled": true
+ },
+ "outputs": [],
+ "source": [
+ "#Anmelden und token holen\n",
+ "from farmOS import farmOS\n",
+ "\n",
+ "hostname = \"farmos.wagframe.duckdns.org\"\n",
+ "username = \"matze\"\n",
+ "password = \"m6ChEHx5gMqgctr8dpb3fhATZbQS8hv4\"\n",
+ "\n",
+ "# Create the client.\n",
+ "farm_client = farmOS(\n",
+ " hostname=hostname,\n",
+ " client_id = \"jupyter\", # Optional. The default oauth client_id \"farm\" is enabled on all farmOS servers.\n",
+ ")\n",
+ "import json\n",
+ "# Authorize the client, save the token.\n",
+ "# A scope can be specified, but will default to the default scope set when initializing the client.\n",
+ "token = farm_client.authorize(username, password)\n",
+ "#farm_client.info()\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "dcf25e45-f887-4fd5-aed8-44090ed75680",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Die Datei wurde erfolgreich unter '/Users/Wir/Downloads/assets_1.xlsx' gespeichert.\n"
+ ]
+ }
+ ],
+ "source": [
+ "#Excel Export\n",
+ "import os\n",
+ "# Definiere den Basispfad und den Dateinamen\n",
+ "base_file_path = '/Users/Wir/Downloads/assets'\n",
+ "file_extension = '.xlsx'\n",
+ "file_index = 1\n",
+ "file_path = f\"{base_file_path}_{file_index}{file_extension}\"\n",
+ "\n",
+ "# Überprüfe, ob die Datei bereits existiert und erhöhe den Index\n",
+ "while os.path.exists(file_path):\n",
+ " file_index += 1\n",
+ " file_path = f\"{base_file_path}_{file_index}{file_extension}\"\n",
+ "\n",
+ "# Exportiere den DataFrame in eine Excel-Datei\n",
+ "df.to_excel(file_path, index=False)\n",
+ "print(f\"Die Datei wurde erfolgreich unter '{file_path}' gespeichert.\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d6022671-c929-4dbb-b60c-8d0ce17a1663",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#API Info\n",
+ "\n",
+ "info = farm_client.info()\n",
+ "info"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "ca74d822-4f5c-46d7-8129-31bbf28a1e00",
+ "metadata": {
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true,
+ "source_hidden": true
+ },
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Name | \n",
+ " Status | \n",
+ " Created | \n",
+ " Area (ha) | \n",
+ " Asset type | \n",
+ " Is fixed | \n",
+ " land_type | \n",
+ " Is location | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " Helmacker | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 3.0321 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " Neureut | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 4.1875 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " Schusterinsel | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 4.9563 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " Kesselacker | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 2.1625 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " Kapelle | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 5.6771 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " Loehle | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 2.0614 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " Kirchenberg | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 2.4701 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " Nachtweide | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 3.0704 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " Steinacker | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 2.6109 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " Siegelwoerth | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 0.7707 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " Waethle | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 1.4308 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " Wolfsfeld | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 3.5169 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 12 | \n",
+ " Grosser Acker | \n",
+ " active | \n",
+ " 06.05.2024 | \n",
+ " 12.5316 | \n",
+ " asset--land | \n",
+ " True | \n",
+ " field | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Name Status Created Area (ha) Asset type Is fixed land_type Is location\n",
+ "0 Helmacker active 06.05.2024 3.0321 asset--land True field True\n",
+ "1 Neureut active 06.05.2024 4.1875 asset--land True field True\n",
+ "2 Schusterinsel active 06.05.2024 4.9563 asset--land True field True\n",
+ "3 Kesselacker active 06.05.2024 2.1625 asset--land True field True\n",
+ "4 Kapelle active 06.05.2024 5.6771 asset--land True field True\n",
+ "5 Loehle active 06.05.2024 2.0614 asset--land True field True\n",
+ "6 Kirchenberg active 06.05.2024 2.4701 asset--land True field True\n",
+ "7 Nachtweide active 06.05.2024 3.0704 asset--land True field True\n",
+ "8 Steinacker active 06.05.2024 2.6109 asset--land True field True\n",
+ "9 Siegelwoerth active 06.05.2024 0.7707 asset--land True field True\n",
+ "10 Waethle active 06.05.2024 1.4308 asset--land True field True\n",
+ "11 Wolfsfeld active 06.05.2024 3.5169 asset--land True field True\n",
+ "12 Grosser Acker active 06.05.2024 12.5316 asset--land True field True"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "#Zeige alle \"Land\" Daten\n",
+ "import pandas as pd\n",
+ "from shapely.geometry import Polygon\n",
+ "from shapely import wkt # for converting WKT string to shapely Polygon\n",
+ "from pyproj import CRS, Transformer # for coordinate transformation (if necessary)\n",
+ "\n",
+ "# Assuming this is your response\n",
+ "response = farm_client.asset.get('land')\n",
+ "all_land_assets = response['data']\n",
+ "\n",
+ "# Function to calculate area in hectares\n",
+ "def calculate_area(geometry_wkt):\n",
+ " # Convert WKT (Well-Known Text) to Polygon\n",
+ " polygon = wkt.loads(geometry_wkt)\n",
+ "\n",
+ " # Define the CRS (Coordinate Reference System) for the land's coordinates\n",
+ " crs_wgs84 = CRS(\"EPSG:4326\") # WGS 84, latitude-longitude\n",
+ " crs_projected = CRS(\"EPSG:25832\") # A projected CRS for accurate area calculation\n",
+ "\n",
+ " # Transform coordinates to a projected CRS for area calculation\n",
+ " transformer = Transformer.from_crs(crs_wgs84, crs_projected, always_xy=True)\n",
+ " projected_polygon = Polygon([transformer.transform(*coord) for coord in polygon.exterior.coords])\n",
+ "\n",
+ " # Calculate the area in square meters and convert to hectares\n",
+ " area_sq_meters = projected_polygon.area\n",
+ " area_hectares = area_sq_meters / 10_000 # 1 hectare = 10,000 square meters\n",
+ "\n",
+ " # Round to 4 decimal places\n",
+ " return round(area_hectares, 4)\n",
+ "\n",
+ "\n",
+ "land_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \"Area (ha)\": calculate_area(asset[\"attributes\"][\"intrinsic_geometry\"][\"value\"]),\n",
+ " \"Asset type\": asset[\"type\"],\n",
+ " \"Is fixed\": asset[\"attributes\"][\"is_fixed\"],\n",
+ " \"land_type\": asset[\"attributes\"][\"land_type\"],\n",
+ " \"Is location\": asset[\"attributes\"][\"is_location\"]\n",
+ " }\n",
+ " for asset in all_land_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(land_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "33c1b024-fb74-472c-b229-36d8041b1336",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"Plant\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "\n",
+ "# Assuming this is your response\n",
+ "response = farm_client.asset.get('plant')\n",
+ "all_plant_assets = response['data']\n",
+ "\n",
+ "\n",
+ "\n",
+ "plant_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_plant_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(plant_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d64e0dc4-a685-4a42-810c-cafd8f43b988",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"equipment\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "\n",
+ "# Assuming this is your response\n",
+ "response = farm_client.asset.get('equipment')\n",
+ "all_equipment_assets = response['data']\n",
+ "\n",
+ "\n",
+ "\n",
+ "equipment_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_equipment_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(equipment_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "718ed35b-39f5-4732-8967-8f204e41f653",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"material\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "\n",
+ "# Assuming this is your response\n",
+ "response = farm_client.asset.get('material')\n",
+ "all_material_assets = response['data']\n",
+ "\n",
+ "\n",
+ "\n",
+ "material_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_material_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(material_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "7e3ac788-1146-4aa3-a155-4f5d0c16ef02",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"product\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "\n",
+ "# Assuming this is your response\n",
+ "response = farm_client.asset.get('product')\n",
+ "all_product_assets = response['data']\n",
+ "\n",
+ "\n",
+ "\n",
+ "product_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_product_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(product_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "96784d50-f9bf-43a2-ae95-1e53f9c8ffb4",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"seed\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "\n",
+ "# Assuming this is your response\n",
+ "response = farm_client.asset.get('seed')\n",
+ "all_seed_assets = response['data']\n",
+ "\n",
+ "\n",
+ "\n",
+ "seed_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_seed_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(seed_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "22b12932-9e79-4cfe-ab03-9a76d93a7a3f",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"harvest\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "response = farm_client.log.get('harvest')\n",
+ "all_harvest_assets = response['data']\n",
+ "\n",
+ "harvest_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_harvest_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(harvest_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "0d6a676c-94cb-4d9e-8c3b-24a40be73dea",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"activity\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "response = farm_client.log.get('activity')\n",
+ "all_activity_assets = response['data']\n",
+ "\n",
+ "activity_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_activity_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(activity_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "3dab14bd-e7e6-4a5f-b838-c6498fb20f23",
+ "metadata": {
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true,
+ "source_hidden": true
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Name | \n",
+ " Status | \n",
+ " Created | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " Innovert Raps Input 24/25 | \n",
+ " done | \n",
+ " 14.10.2024 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Name Status Created\n",
+ "0 Innovert Raps Input 24/25 done 14.10.2024"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "#Zeige alle \"input\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "response = farm_client.log.get('input')\n",
+ "all_input_assets = response['data']\n",
+ "\n",
+ "input_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_input_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(input_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "625d3e17-635c-4775-94e7-a0179cf690de",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"maintenance\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "response = farm_client.log.get('maintenance')\n",
+ "all_maintenance_assets = response['data']\n",
+ "\n",
+ "maintenance_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_maintenance_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(maintenance_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "bad0e10e-a112-45b0-a454-672348389dea",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"medical\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "response = farm_client.log.get('medical')\n",
+ "all_medical_assets = response['data']\n",
+ "\n",
+ "medical_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_medical_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(medical_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "a08ff50e-499c-497d-879c-85c0c9b107c2",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#Zeige alle \"seeding\" Daten\n",
+ "import pandas as pd\n",
+ "\n",
+ "response = farm_client.log.get('seeding')\n",
+ "all_seeding_assets = response['data']\n",
+ "\n",
+ "seeding_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " \n",
+ " }\n",
+ " for asset in all_seeding_assets\n",
+ "]\n",
+ "\n",
+ "# Create a pandas DataFrame from the extracted data\n",
+ "df = pd.DataFrame(seeding_asset_data)\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die Tabelle an\n",
+ "df\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "64a933c4-75b3-4dd5-902c-5da2850d585f",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": true
+ }
+ },
+ "outputs": [],
+ "source": [
+ "#filter auf einen harvest log\n",
+ "import pandas as pd\n",
+ "\n",
+ "response = farm_client.log.get('harvest')\n",
+ "all_harvest_assets = response['data']\n",
+ "\n",
+ "harvest_asset_data = [\n",
+ " {\n",
+ " \"Name\": asset[\"attributes\"][\"name\"],\n",
+ " \"Status\": asset[\"attributes\"][\"status\"],\n",
+ " \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
+ " }\n",
+ " for asset in all_harvest_assets\n",
+ "]\n",
+ "\n",
+ "# Erstelle ein Pandas DataFrame aus den extrahierten Daten\n",
+ "df = pd.DataFrame(harvest_asset_data)\n",
+ "\n",
+ "# Filtere den DataFrame, um nur den gewünschten Harvest anzuzeigen (enthält den Teilstring)\n",
+ "df_filtered = df[df['Name'].str.contains(\"Helmacker\", na=False)]\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "# Zeige die gefilterte Tabelle an\n",
+ "df_filtered\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "d23c84ac-9a04-4019-9b0c-0c549620af35",
+ "metadata": {
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true,
+ "source_hidden": true
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Name | \n",
+ " Timestamp | \n",
+ " Plant | \n",
+ " Status | \n",
+ " Revision Created | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " W-Raps Helmacker Harvest 24/25 | \n",
+ " 2024-10-20T10:11:15+00:00 | \n",
+ " W-Raps Helmacker Plant 24/25 | \n",
+ " done | \n",
+ " 2024-10-21T10:56:27+00:00 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Name Timestamp Plant Status Revision Created\n",
+ "0 W-Raps Helmacker Harvest 24/25 2024-10-20T10:11:15+00:00 W-Raps Helmacker Plant 24/25 done 2024-10-21T10:56:27+00:00"
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "#Versuch\n",
+ "import pandas as pd\n",
+ "\n",
+ "\n",
+ "def get_related_logs_of_type(asset, type): \n",
+ " response = farm_client.resource.get('log', type)\n",
+ " ret = []\n",
+ " for log in response['data']:\n",
+ " assets = log['relationships']['asset']['data']\n",
+ " for asset in assets:\n",
+ " if asset['id'] == id:\n",
+ " ret.append(log)\n",
+ " return ret\n",
+ "\n",
+ "def get_related_quantities_of_measure(log, measure):\n",
+ " quantities = log['relationships']['quantity']['data']\n",
+ " ret = []\n",
+ " for quant_ref in quantities:\n",
+ " quant_id = quant_ref['id']\n",
+ " quant = farm_client.resource.get_id('quantity', 'standard', quant_id)\n",
+ " if quant['data']['attributes']['measure'] == measure:\n",
+ " ret.append(quant)\n",
+ " return ret\n",
+ "\n",
+ "# Beispiel für eine API-Abfrage mit farm_client\n",
+ "response = farm_client.resource.get('log', 'harvest')\n",
+ "\n",
+ "logs = []\n",
+ "for item in response['data']:\n",
+ " # plant name und fläche holen\n",
+ " assets = item['relationships']['asset']['data']\n",
+ " plant_name = ''\n",
+ " plant_area = 0.0\n",
+ " for asset in assets:\n",
+ " if asset['type'] == 'asset--plant': \n",
+ " plant_id = asset['id']\n",
+ " seedings = get_related_logs_of_type(plant_id, 'seeding')\n",
+ " \n",
+ " plant = farm_client.asset.get_id('plant', plant_id)\n",
+ " plant_name = plant['data']['attributes']['name']\n",
+ " \n",
+ " \n",
+ " # log aufbauen\n",
+ " log = {\n",
+ " \n",
+ " 'Name': item['attributes']['name'],\n",
+ " 'Timestamp': item['attributes']['timestamp'],\n",
+ " 'Plant': plant_name,\n",
+ " \n",
+ " 'Status': item['attributes']['status'],\n",
+ " 'Revision Created': item['attributes']['revision_created'],\n",
+ " }\n",
+ " logs.append(log)\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Erstelle ein Pandas DataFrame aus den extrahierten Daten\n",
+ "df = pd.DataFrame(logs)\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Setze Pandas-Optionen für eine bessere Anzeige\n",
+ "pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
+ "pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
+ "pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
+ "\n",
+ "df\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "c74becaa-5899-4ad0-bb6e-5399cc5d0aa2",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.12.5"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}