Compare commits

...

9 Commits

13 changed files with 1190 additions and 60 deletions

4
.gitignore vendored
View File

@@ -2,8 +2,10 @@
# project specific gitignore entries
.venv
*.txt
*temp/
*.xlsx
*.pdf
*.csv
*temp/
########################################################################################
# project specific gitignore entries

79
LaTex/Ruder-IDs.csv Normal file
View File

@@ -0,0 +1,79 @@
S-C2-M-19XX-01-B/S
S-Sw-M-201X-01-B/S
S-Sw-M-201X-02-B/S
S-Sw-M-201X-03-B/S
S-Sw-M-201X-04-B/S
S-Cr-M-200X-01-B/S
S-Cr-M-200X-02-B/S
S-Cr-M-200X-03-B/S
S-Cr-M-200X-04-B/S
S-Cr-M-200X-05-B/S
S-Cr-M-200X-06-B/S
S-Cr-M-200X-07-B/S
S-Cr-M-200X-08-B/S
S-Cr-M-200X-09-B/S
S-Cr-M-200X-10-B/S
S-Cr-M-200X-11-B/S
S-Cr-H-200X-01-B/S
S-Cr-H-200X-02-B/S
S-Cr-H-200X-03-B/S
S-Cr-H-200X-04-B/S
S-Cr-H-200X-05-B/S
S-C2-H-201X-01-B/S
S-C2-H-201X-02-B/S
S-C2-H-201X-03-B/S
S-C2-H-201X-04-B/S
S-C2-H-201X-05-B/S
S-C2-H-201X-06-B/S
S-C2-H-201X-07-B/S
S-C2-H-201X-08-B/S
S-C2-H-201X-09-B/S
S-C2-H-201X-10-B/S
S-C2-H-201X-11-B/S
S-C2-H-201X-12-B/S
S-C2-H-201X-13-B/S
S-C2-H-201X-14-B/S
S-C2-H-201X-15-B/S
S-C2-H-201X-16-B/S
S-C2-H-201X-17-B/S
S-C2-H-201X-20-B/S-sk
S-C2-H-201X-21-B/S-sk
S-C2-H-201X-22-B/S-sk
S-C2-H-201X-23-B/S-sk
S-C2-H-201X-24-B/S-sk
S-C2-H-201X-25-B/S-sk
S-C2-H-201X-26-B/S-sk
S-C2-H-202X-01-B/S-sk
S-C2-H-202X-02-B/S-sk
S-C2-H-202X-03-B/S-sk
R-Em-H-19XX-00/01
R-Em-H-19XX-02/3
R-Em-H-19XX-02/03
R-Em-H-19XX-04/5
R-Em-H-19XX-04/05
R-Em-H-19XX-06/7
R-Em-H-19XX-06/07
R-Em-H-19XX-08/9
R-Cr-H-200X-00/01
R-Cr-H-200X-02/3
R-Cr-H-200X-02/03
R-Cr-H-200X-04/5
R-Cr-H-200X-04/05
R-Cr-H-200X-06/7
R-Cr-H-200X-06/07
R-Cr-H-200X-08/9
R-Cr-H-200X-08/09
R-Cr-H-200X-10/11
R-Cr-H-200X-12/13
R-Cr-H-200X-14/15
R-C2-H-201X-00/01-sk
R-C2-H-201X-02/3-sk
R-C2-H-201X-02/03-sk
R-C2-H-201X-04/5-sk
R-C2-H-201X-04/05-sk
R-C2-H-201X-06/7-sk
R-C2-H-201X-06/07-sk
R-C2-H-201X-08/9-sk
R-C2-H-201X-08/09-sk
R-C2-H-201X-10/11-sk
R-C2-H-201X-12/13-sk
1 S-C2-M-19XX-01-B/S
2 S-Sw-M-201X-01-B/S
3 S-Sw-M-201X-02-B/S
4 S-Sw-M-201X-03-B/S
5 S-Sw-M-201X-04-B/S
6 S-Cr-M-200X-01-B/S
7 S-Cr-M-200X-02-B/S
8 S-Cr-M-200X-03-B/S
9 S-Cr-M-200X-04-B/S
10 S-Cr-M-200X-05-B/S
11 S-Cr-M-200X-06-B/S
12 S-Cr-M-200X-07-B/S
13 S-Cr-M-200X-08-B/S
14 S-Cr-M-200X-09-B/S
15 S-Cr-M-200X-10-B/S
16 S-Cr-M-200X-11-B/S
17 S-Cr-H-200X-01-B/S
18 S-Cr-H-200X-02-B/S
19 S-Cr-H-200X-03-B/S
20 S-Cr-H-200X-04-B/S
21 S-Cr-H-200X-05-B/S
22 S-C2-H-201X-01-B/S
23 S-C2-H-201X-02-B/S
24 S-C2-H-201X-03-B/S
25 S-C2-H-201X-04-B/S
26 S-C2-H-201X-05-B/S
27 S-C2-H-201X-06-B/S
28 S-C2-H-201X-07-B/S
29 S-C2-H-201X-08-B/S
30 S-C2-H-201X-09-B/S
31 S-C2-H-201X-10-B/S
32 S-C2-H-201X-11-B/S
33 S-C2-H-201X-12-B/S
34 S-C2-H-201X-13-B/S
35 S-C2-H-201X-14-B/S
36 S-C2-H-201X-15-B/S
37 S-C2-H-201X-16-B/S
38 S-C2-H-201X-17-B/S
39 S-C2-H-201X-20-B/S-sk
40 S-C2-H-201X-21-B/S-sk
41 S-C2-H-201X-22-B/S-sk
42 S-C2-H-201X-23-B/S-sk
43 S-C2-H-201X-24-B/S-sk
44 S-C2-H-201X-25-B/S-sk
45 S-C2-H-201X-26-B/S-sk
46 S-C2-H-202X-01-B/S-sk
47 S-C2-H-202X-02-B/S-sk
48 S-C2-H-202X-03-B/S-sk
49 R-Em-H-19XX-00/01
50 R-Em-H-19XX-02/3
51 R-Em-H-19XX-02/03
52 R-Em-H-19XX-04/5
53 R-Em-H-19XX-04/05
54 R-Em-H-19XX-06/7
55 R-Em-H-19XX-06/07
56 R-Em-H-19XX-08/9
57 R-Cr-H-200X-00/01
58 R-Cr-H-200X-02/3
59 R-Cr-H-200X-02/03
60 R-Cr-H-200X-04/5
61 R-Cr-H-200X-04/05
62 R-Cr-H-200X-06/7
63 R-Cr-H-200X-06/07
64 R-Cr-H-200X-08/9
65 R-Cr-H-200X-08/09
66 R-Cr-H-200X-10/11
67 R-Cr-H-200X-12/13
68 R-Cr-H-200X-14/15
69 R-C2-H-201X-00/01-sk
70 R-C2-H-201X-02/3-sk
71 R-C2-H-201X-02/03-sk
72 R-C2-H-201X-04/5-sk
73 R-C2-H-201X-04/05-sk
74 R-C2-H-201X-06/7-sk
75 R-C2-H-201X-06/07-sk
76 R-C2-H-201X-08/9-sk
77 R-C2-H-201X-08/09-sk
78 R-C2-H-201X-10/11-sk
79 R-C2-H-201X-12/13-sk

Binary file not shown.

View File

@@ -20,20 +20,11 @@
\begin{document}
% \maketitle
\begin{center}
\begin{minipage}{0.9\textwidth}
\section*{Ruder ID Format}
% \begin{table}[]
% \centering
% \setlength{\tabcolsep}{40pt} % Adjust column spacing
% \LARGE
% \begin{tabular}{ccccccc}
% \textbf{S1} & \textbf{S2} & \textbf{S3} & \textbf{S4} & \textbf{S5} & \textbf{S6} & \textbf{S7} \\
% \textbf{Typ} & \textbf{Marke} & \textbf{Blatttyp} & \textbf{Anschaffungsjahr} & \textbf{Nummer} & \textbf{Seite} & \textbf{Rest}
% \end{tabular}
% \end{table}
\vspace{15mm}
\begin{table}[]
\centering
@@ -45,13 +36,15 @@
\end{tabular}
\end{table}
\vspace{15mm}
\section*{Erklärung der Segmente}
\begin{table}[h!]
\centering
\setlength{\tabcolsep}{40pt} % Adjust column spacing
\setlength{\tabcolsep}{60pt} % Adjust column spacing
\LARGE
\begin{tabular}{ccccc} % Remove extra space on the sides
\begin{tabular}{|ccccc|} % Remove extra space on the sides
\toprule
\textbf{Segmentnummer} & \textbf{Segmentname} & \textbf{Anzahl Stellen} & \textbf{Wert} & \textbf{Langtext} \\
\midrule
@@ -69,11 +62,12 @@
& & & Em: & Empacher \\
& & & Sw: & Swift Racing \\
\midrule
\multirow{2}{*}{\textbf{S3}} &
\multirow{2}{*}{\textbf{Blatttyp}} &
\multirow{2}{*}{1}
\multirow{3}{*}{\textbf{S3}} &
\multirow{3}{*}{\textbf{Blatttyp}} &
\multirow{3}{*}{1}
& M: & Macon \\
& & & H: & Hacke \\
& & & C: & Comp \\
\midrule
\multirow{4}{*}{\textbf{S4}} &
\multirow{4}{*}{\textbf{Anschaffungsjahr}} &
@@ -103,8 +97,10 @@
\end{tabular}
\end{table}
\vspace{15mm}
\section*{Beispiele}
\vspace{5mm}
\begin{center}
\Huge
\textbf{S-C2-H-201X-99-B-sk}

BIN
LaTex/print_Ruder-IDs.pdf Normal file

Binary file not shown.

27
LaTex/print_Ruder-IDs.tex Normal file
View File

@@ -0,0 +1,27 @@
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{csvsimple}
\usepackage{geometry}
\usepackage{array}
\usepackage{longtable}
\usepackage{anyfontsize}
\usepackage{xcolor}
\usepackage{colortbl}
\geometry{a4paper, margin=0in}
% Define light grey color
\definecolor{lightgrey}{gray}{0.9}
\begin{document}
\begin{center}
\renewcommand{\arraystretch}{1.6}
\bfseries
\fontsize{40}{50}\selectfont % Set font size to 50pt, line spacing to 60pt
\begin{longtable}{>{\centering\arraybackslash}p{\textwidth}}
\\[20pt]
\csvreader[head to column names]{Ruder-IDs.csv}{}{\csvcoli \\[20pt] \arrayrulecolor{lightgrey}\hline \\[20pt]}
\end{longtable}
\end{center}
\end{document}

View File

@@ -226,7 +226,7 @@
" f\"TEL;TYPE=CELL:{phone}\"]\n",
" \n",
" if rower is True:\n",
" lines.append(f'NOTE:JG {year}')\n",
" lines.append(f'NOTE:JG {int(year)}')\n",
"\n",
" if photo_b64:\n",
" lines.append(f\"PHOTO;ENCODING=b;TYPE=JPEG:{photo_b64}\")\n",

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "152c4ce0",
"metadata": {},
"outputs": [],
@@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "041b0ab6",
"metadata": {},
"outputs": [],
@@ -25,12 +25,12 @@
"\n",
"\n",
"# Modern Nextcloud WebDAV endpoint format:\n",
"WEBDAV_BASE_URL = f\"{NEXTCLOUD_URL}/remote.php/dav/files/{USERNAME}/Shared/Ruderverein/Videoanalyse\""
"WEBDAV_BASE_URL = f\"{NEXTCLOUD_URL}/remote.php/dav/files/{USERNAME}/Shared/Ruderverein/02_Athlet:innen/01_Videoanalyse\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "19ec4c3e",
"metadata": {},
"outputs": [],
@@ -45,7 +45,7 @@
" # WebDAV returns 405 Method Not Allowed if the folder already exists\n",
" print(f\"⏩ Skipped: Folder already exists at {folder_url}\")\n",
" elif response.status_code == 409:\n",
" print(f\" Error: Parent folder doesn't exist for {folder_url}\")\n",
" print(f\" Error: Parent folder doesn't exist for {folder_url}\")\n",
" else:\n",
" print(f\"❌ Error {response.status_code}: Could not create folder.\")\n",
" print(response.text)"
@@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "b4c04efb",
"metadata": {},
"outputs": [],
@@ -107,43 +107,10 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "306aef25",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"⏩ Skipped: Folder already exists at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse\n",
"Fetching contacts from the 'rv-villach-athletinnen' address book...\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Aufegger%20Tobias\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Praschnig%20Flora\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Buchacher%20Eva\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Gigacher%20Olivia\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/McGrath%20Samuel\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Magdalena%20Truppe\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Yang%20Ruien\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Yang%20Xiaoen\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Kofler%20Hannah\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Tropea%20Manfredi\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Spath-Glantschnig%20%20Christoph\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Acerbi%20Sofia\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Aufegger%20Emilia\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Henriks%20Alva\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Tscherne%20Tobias\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Pressinger%20Laurin\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Bodner%20Emma\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Jop%20Nicolas\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Assmann-Hafenscherer%20Felix\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Henriks%20Konstantin\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Loidl%20Lieselotte\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Poga%C4%8Dar%20Anamary\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Polessnig%20Valentina\n",
"✅ Success: Created folder at https://nextcloud.karnelegger.eu/remote.php/dav/files/Georg Brantegger/Shared/Ruderverein/Videoanalyse/Paulik%20Elena\n"
]
}
],
"outputs": [],
"source": [
"# 1. Create the main base folder first (just in case it doesn't exist)\n",
"create_nextcloud_folder(WEBDAV_BASE_URL)\n",

View File

@@ -0,0 +1,209 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "152c4ce0",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import pandas as pd\n",
"import datetime as dt\n",
"import openpyxl.styles"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "041b0ab6",
"metadata": {},
"outputs": [],
"source": [
"# --- Configuration ---\n",
"NEXTCLOUD_URL = \"https://nextcloud.karnelegger.eu\"\n",
"USERNAME = \"Georg Brantegger\"\n",
"with open('app_pw.txt','r') as f:\n",
" APP_PASSWORD = f.readline()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b4c04efb",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import vobject\n",
"\n",
"\n",
"# This is the \"URL slug\" of your address book. \n",
"# Usually, if you name it \"Athletes\", the slug is \"athletes\" (lowercase).\n",
"# You can find the exact name by going to Contacts -> Settings (bottom left) -> \n",
"# Click the 3 dots next to your address book -> \"Copy link\". \n",
"# The link will end with /addressbooks/users/username/THIS_PART/\n",
"ADDRESSBOOK_NAME = \"rv-villach-athletinnen\" \n",
"\n",
"\n",
"# The ?export parameter tells Nextcloud to dump the whole address book at once\n",
"CARDDAV_URL = f\"{NEXTCLOUD_URL}/remote.php/dav/addressbooks/users/{USERNAME}/{ADDRESSBOOK_NAME}/?export\"\n",
"\n",
"def get_athlete_data():\n",
" print(f\"Fetching contacts from the '{ADDRESSBOOK_NAME}' address book...\")\n",
" response = requests.get(CARDDAV_URL, auth=(USERNAME, APP_PASSWORD))\n",
" \n",
" if response.status_code != 200:\n",
" print(f\"❌ Error {response.status_code}: Could not fetch address book.\")\n",
" print(\"Check your URL, credentials, and make sure the ADDRESSBOOK_NAME is exactly right.\")\n",
" return []\n",
"\n",
" vcf_data = response.text\n",
" first_names = []\n",
" last_names = []\n",
" genders = []\n",
" years_of_birth = []\n",
"\n",
" # Parse the multi-contact VCF data\n",
" for vcard in vobject.readComponents(vcf_data):\n",
" # The 'n' property in a vCard holds the structured Name (First, Last, etc.)\n",
" if hasattr(vcard, 'n'):\n",
" first_name = vcard.n.value.given\n",
" last_name = vcard.n.value.family\n",
" \n",
" first_names.append(first_name)\n",
" last_names.append(last_name)\n",
" else: print(vcard.fn.value)\n",
" \n",
" if hasattr(vcard, 'note'):\n",
" [_,year_of_birth,gender] = vcard.note.value.split(' ')\n",
" \n",
" genders.append(gender)\n",
" years_of_birth.append(int(year_of_birth))\n",
" \n",
" return last_names,first_names,genders,years_of_birth"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3efe3bb1",
"metadata": {},
"outputs": [],
"source": [
"a,b,c,d = get_athlete_data()\n",
"data_dict = {'Nachname':a,'Vorname':b,'Gender':c,'Jahrgang':d}\n",
"\n",
"df = pd.DataFrame(data_dict)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a65d7693",
"metadata": {},
"outputs": [],
"source": [
"def evaluate_class(row):\n",
" gender = row['Gender']\n",
" yob = row['Jahrgang']\n",
" age = dt.datetime.now().year - yob\n",
" \n",
" if age <= 12:\n",
" c1 = 'Sch'\n",
" c2 = 'B'\n",
" elif 12 < age <= 14:\n",
" c1 = 'Sch'\n",
" c2 = 'A'\n",
" elif 14 < age <= 16:\n",
" c1 = 'Jun'\n",
" c2 = 'B'\n",
" elif 16 < age <= 18:\n",
" c1 = 'Jun'\n",
" c2 = 'A'\n",
" elif 18 < age <= 23:\n",
" c1 = 'Sen'\n",
" c2 = 'B'\n",
" elif 23 < age <= 30:\n",
" c1 = 'Sen'\n",
" c2 = 'A'\n",
" \n",
" return f'{c1}-{gender}-{c2}'\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "529f37c2",
"metadata": {},
"outputs": [],
"source": [
"df['Klasse'] = df.apply(evaluate_class,axis=1)\n",
"df[f'Ruderpass {dt.datetime.now().year}'] = 0"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7ff6f41c",
"metadata": {},
"outputs": [],
"source": [
"file_name = 'temp.xlsx'\n",
"\n",
"with pd.ExcelWriter(file_name, engine='openpyxl') as writer:\n",
" \n",
" df_styled = df.style.set_properties(**{'text-align': 'center'})\n",
" # 2 Write to xlsx\n",
" df_styled.to_excel(writer, sheet_name=\"Athlet_innen\",index=False)\n",
"\n",
" # 3 after writing, change other formats\n",
" # --- Access the openpyxl worksheet object ---\n",
" worksheet = writer.sheets[\"Athlet_innen\"]\n",
"\n",
" # 3.2 format the header\n",
" # Define a bold, larger font\n",
" header_font = openpyxl.styles.Font(name='Arial', size=12, bold=True, color=\"000000\")\n",
"\n",
" worksheet.column_dimensions['A'].width = 18*1.63\n",
" worksheet.column_dimensions['B'].width = 18*0.86\n",
" worksheet.column_dimensions['C'].width = 18*0.72\n",
" worksheet.column_dimensions['D'].width = 18*0.91\n",
" worksheet.column_dimensions['E'].width = 18*0.72\n",
" worksheet.column_dimensions['F'].width = 18*1.45\n",
"\n",
" \n",
" # Iterate through the first row (Header)\n",
" # worksheet[1] returns all cells in the first row\n",
" for cell in worksheet[1]:\n",
" cell.font = header_font\n",
" cell.alignment = openpyxl.styles.Alignment(horizontal='center', vertical='center')\n",
" cell.border = openpyxl.styles.Border(bottom=openpyxl.styles.Side(border_style='medium', color='000000'))\n",
"\n",
" # 3.3 freeze the first row\n",
" worksheet.freeze_panes = 'A2' "
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -0,0 +1,193 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 25,
"id": "f46948ac",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import pandas as pd\n",
"from io import BytesIO"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "3a1de802",
"metadata": {},
"outputs": [],
"source": [
"# --- Configuration ---\n",
"NEXTCLOUD_URL = \"https://nextcloud.karnelegger.eu\"\n",
"USERNAME = \"Georg Brantegger\"\n",
"with open('app_pw.txt','r') as f:\n",
" APP_PASSWORD = f.readline()\n"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "1fdfef34",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"File loaded successfully!\n"
]
}
],
"source": [
"# read list of boats\n",
"\n",
"FILE_PATH = \"Shared/Ruderverein/01_Material/01_Bootsliste.xlsx\"\n",
"\n",
"# Build the WebDAV URL\n",
"# Note: Path should be URL-encoded if it contains spaces or special characters\n",
"webdav_url = f\"{NEXTCLOUD_URL}/remote.php/dav/files/{USERNAME}/{FILE_PATH}\"\n",
"\n",
"# --- The Request ---\n",
"response = requests.get(webdav_url, auth=(USERNAME, APP_PASSWORD))\n",
"\n",
"if response.status_code == 200:\n",
" # Use BytesIO to turn the raw binary content into a file-like object\n",
" boats_df = pd.read_excel(BytesIO(response.content))\n",
" print(\"File loaded successfully!\")\n",
"else:\n",
" print(f\"Failed to fetch file. Status code: {response.status_code}\")\n",
" print(response.text)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "80f97e18",
"metadata": {},
"outputs": [],
"source": [
"def analyse_class(row):\n",
" boot_class = row['Bootsklasse']\n",
"\n",
" number_seats = 0\n",
" variable = False\n",
"\n",
" for i in range(8+1):\n",
" if str(i) in boot_class:\n",
" number_seats = i\n",
" break\n",
" \n",
" if '/' in boot_class:\n",
" variable = True\n",
"\n",
" return number_seats, variable\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "70fb2327",
"metadata": {},
"outputs": [],
"source": [
"boats_df[['number_seats','variable']] = boats_df.apply(analyse_class,axis=1,result_type='expand')"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "bf18a0fd",
"metadata": {},
"outputs": [],
"source": [
"boat_names = []\n",
"variants = []\n",
"places = []\n",
"\n",
"for boat_name in boats_df['Name'].unique():\n",
" number_seats = boats_df.loc[boats_df['Name']==boat_name,'number_seats'].values[0]\n",
" variable = boats_df.loc[boats_df['Name']==boat_name,'variable'].values[0]\n",
"\n",
" if bool(variable) is False:\n",
" for place in range(1,number_seats+1):\n",
" boat_names.append(boat_name.strip())\n",
" variants.append(f\"{number_seats}x\")\n",
" places.append(place)\n",
" elif bool(variable) is True:\n",
" for place in range(1,number_seats+1):\n",
" boat_names.append(boat_name.strip())\n",
" variants.append(f\"{number_seats}x\")\n",
" places.append(place)\n",
" for place in range(1,number_seats+1):\n",
" boat_names.append(boat_name.strip())\n",
" variants.append(f\"{number_seats}-\")\n",
" places.append(place)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "85059518",
"metadata": {},
"outputs": [],
"source": [
"data_dict = {'Bootsname':boat_names,'Trimmung':variants,'Bootsplatz':places,'Ruder-ID Macon':[None for _ in boat_names],'Ruder-ID Hacke':[None for _ in boat_names]}\n",
"places_df = pd.DataFrame(data_dict)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "7c4f5c01",
"metadata": {},
"outputs": [],
"source": [
"places_df['sort_value'] = places_df['Bootsname'].str.lower()"
]
},
{
"cell_type": "code",
"execution_count": 56,
"id": "edd22b3f",
"metadata": {},
"outputs": [],
"source": [
"places_df.sort_values(by='sort_value',inplace=True,ignore_index=True)"
]
},
{
"cell_type": "code",
"execution_count": 58,
"id": "3071bf52",
"metadata": {},
"outputs": [],
"source": [
"places_df[['Bootsname','Trimmung','Bootsplatz','Ruder-ID Macon','Ruder-ID Hacke']].to_excel('temp.xlsx')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -0,0 +1,144 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"id": "3a384a62",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import pandas as pd\n",
"from io import BytesIO\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "05055b94",
"metadata": {},
"outputs": [],
"source": [
"# --- Configuration ---\n",
"NEXTCLOUD_URL = \"https://nextcloud.karnelegger.eu\"\n",
"USERNAME = \"Georg Brantegger\"\n",
"with open('app_pw.txt','r') as f:\n",
" APP_PASSWORD = f.readline()\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "13fb9852",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"File loaded successfully!\n"
]
}
],
"source": [
"# read list of boats\n",
"\n",
"FILE_PATH = \"Shared/Ruderverein/01_Material/02_Ruderliste.xlsx\"\n",
"\n",
"# Build the WebDAV URL\n",
"# Note: Path should be URL-encoded if it contains spaces or special characters\n",
"webdav_url = f\"{NEXTCLOUD_URL}/remote.php/dav/files/{USERNAME}/{FILE_PATH}\"\n",
"\n",
"# --- The Request ---\n",
"response = requests.get(webdav_url, auth=(USERNAME, APP_PASSWORD))\n",
"\n",
"if response.status_code == 200:\n",
" # Use BytesIO to turn the raw binary content into a file-like object\n",
" oars_df = pd.read_excel(BytesIO(response.content),sheet_name='Ruder')\n",
" print(\"File loaded successfully!\")\n",
"else:\n",
" print(f\"Failed to fetch file. Status code: {response.status_code}\")\n",
" print(response.text)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "16e39eff",
"metadata": {},
"outputs": [],
"source": [
"printing_df = oars_df['Ruder-ID'].to_frame()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "28fcc50d",
"metadata": {},
"outputs": [],
"source": [
"def create_label_from_oar_id(row):\n",
" oar_id = row['Ruder-ID']\n",
"\n",
" parts = oar_id.split('-')\n",
" if parts[0] == 'S':\n",
" parts[5] = 'B/S'\n",
" elif parts[0] == 'R':\n",
" if int(parts[4])%2 == 0:\n",
" parts[4] = parts[4] +'/' f'{int(parts[4])+1}'.zfill(2)\n",
" else:\n",
" parts[4] = f'{int(parts[4])-1}'.zfill(2)+'/'+parts[4]\n",
" parts.remove(parts[5])\n",
"\n",
"\n",
" return '-'.join(parts)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "e3992d5c",
"metadata": {},
"outputs": [],
"source": [
"printing_df['label']=printing_df.apply(create_label_from_oar_id,axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "d6394323",
"metadata": {},
"outputs": [],
"source": [
"parent_folder = os.path.dirname(os.getcwd())\n",
"target_path = os.path.join(parent_folder,'LaTex','Ruder-IDs.csv')\n",
"export_df = printing_df.drop_duplicates(subset='label')\n",
"export_df['label'].to_csv(target_path,index=False,header=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -0,0 +1,423 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 40,
"id": "3a384a62",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import pandas as pd\n",
"from io import BytesIO\n",
"import os\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "05055b94",
"metadata": {},
"outputs": [],
"source": [
"# --- Configuration ---\n",
"NEXTCLOUD_URL = \"https://nextcloud.karnelegger.eu\"\n",
"USERNAME = \"Georg Brantegger\"\n",
"with open('app_pw.txt','r') as f:\n",
" APP_PASSWORD = f.readline()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "13fb9852",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"File loaded successfully!\n",
"File loaded successfully!\n"
]
}
],
"source": [
"# read list of boats\n",
"\n",
"FILE_PATH_1 = \"Shared/Ruderverein/01_Material/02_Ruderliste.xlsx\"\n",
"\n",
"# Build the WebDAV URL\n",
"# Note: Path should be URL-encoded if it contains spaces or special characters\n",
"webdav_url = f\"{NEXTCLOUD_URL}/remote.php/dav/files/{USERNAME}/{FILE_PATH_1}\"\n",
"\n",
"# --- The Request ---\n",
"response = requests.get(webdav_url, auth=(USERNAME, APP_PASSWORD))\n",
"\n",
"if response.status_code == 200:\n",
" # Use BytesIO to turn the raw binary content into a file-like object\n",
" oars_df = pd.read_excel(BytesIO(response.content),sheet_name='Ruder',index_col=0)\n",
" print(\"File loaded successfully!\")\n",
"else:\n",
" print(f\"Failed to fetch file. Status code: {response.status_code}\")\n",
" print(response.text)\n",
"\n",
"FILE_PATH_2 = \"Shared/Ruderverein/01_Material/03_Bootsplatz-Ruder-Zuordnung.xlsx\"\n",
"\n",
"# Build the WebDAV URL\n",
"# Note: Path should be URL-encoded if it contains spaces or special characters\n",
"webdav_url = f\"{NEXTCLOUD_URL}/remote.php/dav/files/{USERNAME}/{FILE_PATH_2}\"\n",
"\n",
"# --- The Request ---\n",
"response = requests.get(webdav_url, auth=(USERNAME, APP_PASSWORD))\n",
"\n",
"if response.status_code == 200:\n",
" # Use BytesIO to turn the raw binary content into a file-like object\n",
" places_df = pd.read_excel(BytesIO(response.content),sheet_name='Bootsplatz_Zuordnung').fillna('')\n",
" print(\"File loaded successfully!\")\n",
"else:\n",
" print(f\"Failed to fetch file. Status code: {response.status_code}\")\n",
" print(response.text)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "16e39eff",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Länge Ruder gesamt</th>\n",
" <th>Länge Innenhebel</th>\n",
" <th>Anlage</th>\n",
" <th>Länge Ruder min</th>\n",
" <th>Länge Ruder max</th>\n",
" <th>Skinny Typ</th>\n",
" <th>Bootsplatz 1</th>\n",
" <th>Bootsplatz 2</th>\n",
" <th>Bootsplatz 3</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Ruder-ID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>R-C2-H-201X-01-S-sk</th>\n",
" <td>370.5</td>\n",
" <td>111.0</td>\n",
" <td>+1</td>\n",
" <td>370.0</td>\n",
" <td>375.0</td>\n",
" <td>MEDFLEX</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>R-C2-H-201X-02-B-sk</th>\n",
" <td>370.0</td>\n",
" <td>111.0</td>\n",
" <td>-3,5</td>\n",
" <td>370.0</td>\n",
" <td>375.0</td>\n",
" <td>MEDFLEX</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>R-C2-H-201X-03-S-sk</th>\n",
" <td>370.5</td>\n",
" <td>111.5</td>\n",
" <td>+1</td>\n",
" <td>370.0</td>\n",
" <td>375.0</td>\n",
" <td>MEDFLEX</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>R-C2-H-201X-04-B-sk</th>\n",
" <td>370.0</td>\n",
" <td>111.5</td>\n",
" <td>-2</td>\n",
" <td>370.0</td>\n",
" <td>375.0</td>\n",
" <td>MEDFLEX</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>R-C2-H-201X-05-S-sk</th>\n",
" <td>374.7</td>\n",
" <td>115.0</td>\n",
" <td>+2</td>\n",
" <td>373.0</td>\n",
" <td>378.0</td>\n",
" <td>MEDFLEX</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S-Sw-M-201X-02-S</th>\n",
" <td>294.0</td>\n",
" <td>88.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S-Sw-M-201X-03-B</th>\n",
" <td>294.0</td>\n",
" <td>88.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S-Sw-M-201X-03-S</th>\n",
" <td>294.0</td>\n",
" <td>88.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S-Sw-M-201X-04-B</th>\n",
" <td>294.0</td>\n",
" <td>88.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S-Sw-M-201X-04-S</th>\n",
" <td>294.0</td>\n",
" <td>88.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>134 rows × 9 columns</p>\n",
"</div>"
],
"text/plain": [
" Länge Ruder gesamt Länge Innenhebel Anlage \\\n",
"Ruder-ID \n",
"R-C2-H-201X-01-S-sk 370.5 111.0 +1 \n",
"R-C2-H-201X-02-B-sk 370.0 111.0 -3,5 \n",
"R-C2-H-201X-03-S-sk 370.5 111.5 +1 \n",
"R-C2-H-201X-04-B-sk 370.0 111.5 -2 \n",
"R-C2-H-201X-05-S-sk 374.7 115.0 +2 \n",
"... ... ... ... \n",
"S-Sw-M-201X-02-S 294.0 88.0 NaN \n",
"S-Sw-M-201X-03-B 294.0 88.0 NaN \n",
"S-Sw-M-201X-03-S 294.0 88.0 NaN \n",
"S-Sw-M-201X-04-B 294.0 88.0 NaN \n",
"S-Sw-M-201X-04-S 294.0 88.0 NaN \n",
"\n",
" Länge Ruder min Länge Ruder max Skinny Typ \\\n",
"Ruder-ID \n",
"R-C2-H-201X-01-S-sk 370.0 375.0 MEDFLEX \n",
"R-C2-H-201X-02-B-sk 370.0 375.0 MEDFLEX \n",
"R-C2-H-201X-03-S-sk 370.0 375.0 MEDFLEX \n",
"R-C2-H-201X-04-B-sk 370.0 375.0 MEDFLEX \n",
"R-C2-H-201X-05-S-sk 373.0 378.0 MEDFLEX \n",
"... ... ... ... \n",
"S-Sw-M-201X-02-S NaN NaN NaN \n",
"S-Sw-M-201X-03-B NaN NaN NaN \n",
"S-Sw-M-201X-03-S NaN NaN NaN \n",
"S-Sw-M-201X-04-B NaN NaN NaN \n",
"S-Sw-M-201X-04-S NaN NaN NaN \n",
"\n",
" Bootsplatz 1 Bootsplatz 2 Bootsplatz 3 \n",
"Ruder-ID \n",
"R-C2-H-201X-01-S-sk NaN NaN NaN \n",
"R-C2-H-201X-02-B-sk NaN NaN NaN \n",
"R-C2-H-201X-03-S-sk NaN NaN NaN \n",
"R-C2-H-201X-04-B-sk NaN NaN NaN \n",
"R-C2-H-201X-05-S-sk NaN NaN NaN \n",
"... ... ... ... \n",
"S-Sw-M-201X-02-S NaN NaN NaN \n",
"S-Sw-M-201X-03-B NaN NaN NaN \n",
"S-Sw-M-201X-03-S NaN NaN NaN \n",
"S-Sw-M-201X-04-B NaN NaN NaN \n",
"S-Sw-M-201X-04-S NaN NaN NaN \n",
"\n",
"[134 rows x 9 columns]"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"oars_df"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "da9397a8",
"metadata": {},
"outputs": [],
"source": [
"places_df['Bootsplatz-Label'] = places_df.apply(lambda row: '_'.join(row[['Bootsname','Trimmung','Bootsplatz']].astype(str).to_list()),axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "43ffb028",
"metadata": {},
"outputs": [],
"source": [
"my_dict = {key:[] for key in oars_df.index.values}\n",
"\n",
"\n",
"for oar_id in my_dict.keys():\n",
" relevant_part = '-'.join(oar_id.split('-')[:5])\n",
"\n",
" for i,row in places_df.iterrows():\n",
" test_macon = '-'.join(row['Ruder-ID Macon'].split('-')[:5])\n",
" test_hacke = '-'.join(row['Ruder-ID Hacke'].split('-')[:5])\n",
" if (relevant_part == test_macon ) | (relevant_part == test_hacke):\n",
" my_dict[oar_id].append(row['Bootsplatz-Label'])\n"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "0b3f5068",
"metadata": {},
"outputs": [],
"source": [
"for oar_id in my_dict.keys():\n",
" places_list = np.array(my_dict[oar_id])\n",
" boat_sizes = [place_label.split('_')[1][0] if len(place_label)>0 else '' for place_label in places_list]\n",
" my_dict[oar_id] = np.flip(places_list[np.argsort(np.array(boat_sizes))])"
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "3a7eb82e",
"metadata": {},
"outputs": [],
"source": [
"my_df = pd.DataFrame.from_dict(my_dict, orient='index',columns=['Bootsplatz 1','Bootsplatz 2','Bootsplatz 3'])"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "d85765c4",
"metadata": {},
"outputs": [],
"source": [
"oars_df[['Bootsplatz 1','Bootsplatz 2','Bootsplatz 3']] = my_df[['Bootsplatz 1','Bootsplatz 2','Bootsplatz 3']]"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "b6848ae9",
"metadata": {},
"outputs": [],
"source": [
"oars_df.to_csv('temp.csv',index=True,sep=';',decimal=',')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -0,0 +1,90 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "e4755f4e",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "689fd1ef",
"metadata": {},
"outputs": [],
"source": [
"# --- Configuration ---\n",
"NEXTCLOUD_URL = \"https://nextcloud.karnelegger.eu\"\n",
"USERNAME = \"Georg Brantegger\"\n",
"with open('app_pw.txt','r') as f:\n",
" APP_PASSWORD = f.readline()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4967214a",
"metadata": {},
"outputs": [],
"source": [
"parent_folder = os.path.dirname(os.getcwd())\n",
"LOCAL_FILE_PATH = os.path.join(parent_folder,'LaTex','print_Ruder-IDs.pdf')\n",
"REMOTE_FILE_PATH = \"Shared/Ruderverein/Material/print_Ruder-IDs.pdf\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "515eaaac",
"metadata": {},
"outputs": [],
"source": [
"\n",
"\n",
"# --- Construction ---\n",
"# The WebDAV endpoint for files is /remote.php/dav/files/USER/\n",
"upload_url = f\"{NEXTCLOUD_URL}/remote.php/dav/files/{USERNAME}/{REMOTE_FILE_PATH}\"\n",
"\n",
"with open(LOCAL_FILE_PATH, 'rb') as f:\n",
" response = requests.put(\n",
" upload_url, \n",
" data=f, \n",
" auth=(USERNAME, APP_PASSWORD)\n",
" )\n",
"\n",
"# --- Results ---\n",
"if response.status_code in [201, 204]:\n",
" print(\"Upload successful!\")\n",
"else:\n",
" print(f\"Failed! Status code: {response.status_code}\")\n",
" print(response.text)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}