diff --git a/Nextcloud Contact Infos/convert_athletes.ipynb b/Nextcloud Contact Infos/convert_athletes.ipynb index 8d8065f..d3d8b91 100644 --- a/Nextcloud Contact Infos/convert_athletes.ipynb +++ b/Nextcloud Contact Infos/convert_athletes.ipynb @@ -141,7 +141,7 @@ "df['Nachname'] = df['Nachname'].str.strip()\n", "df['rower'] = df.apply(evaluate_rower,axis=1,args=('rower',))\n", "df['Telefonnummer'] = df.apply(extract_tel,axis=1,args=('Telefonnummer',))\n", - "df['Foto'] = df['Foto'].str.replace(' ','-')" + "df['Foto'] = df['Foto'].str.replace(' ','-').fillna('-')" ] }, { @@ -165,35 +165,37 @@ "\n", " filename = row['Foto']\n", "\n", - " found_photo = False\n", - " i = 30\n", - " while found_photo is False:\n", - " print(f\"trying folder {i}\")\n", - " folders = [\"Forms\",\"6 - Kontaktdatenerhebung RV Villach\",f\"{i}\",\"23 - photo_name\"]\n", - " folder_string = '/'.join([urllib.parse.quote(folder) for folder in folders])\n", - " filename_photo = urllib.parse.quote(filename)\n", + " if filename != '-':\n", "\n", - " url_photo = '/'.join([base_url,folder_string,urllib.parse.quote(filename_photo)])\n", + " found_photo = False\n", + " i = 30\n", + " while found_photo is False:\n", + " print(f\"trying folder {i}\")\n", + " folders = [\"Forms\",\"6 - Kontaktdatenerhebung RV Villach\",f\"{i}\",\"23 - photo_name\"]\n", + " folder_string = '/'.join([urllib.parse.quote(folder) for folder in folders])\n", + " filename_photo = urllib.parse.quote(filename)\n", "\n", - " r = requests.get(url_photo, auth=(user, app_pw))\n", - " if r.status_code != 200:\n", - " i+=1\n", - " if i > 200:\n", - " break\n", - " continue\n", - " else:\n", - " photo_bytes = r.content\n", - " found_photo = True\n", - " photo_b64 = base64.b64encode(photo_bytes).decode(\"utf-8\")\n", - " \n", - " i = base64.b64decode(photo_b64)\n", - " i = io.BytesIO(i)\n", - " i = mpimg.imread(i, format='JPG')\n", + " url_photo = '/'.join([base_url,folder_string,urllib.parse.quote(filename_photo)])\n", "\n", - " plt.imshow(i, interpolation='nearest')\n", - " plt.show()\n", + " r = requests.get(url_photo, auth=(user, app_pw))\n", + " if r.status_code != 200:\n", + " i+=1\n", + " if i > 200:\n", + " break\n", + " continue\n", + " else:\n", + " photo_bytes = r.content\n", + " found_photo = True\n", + " photo_b64 = base64.b64encode(photo_bytes).decode(\"utf-8\")\n", + " \n", + " i = base64.b64decode(photo_b64)\n", + " i = io.BytesIO(i)\n", + " i = mpimg.imread(i, format='JPG')\n", "\n", - " return photo_b64\n", + " plt.imshow(i, interpolation='nearest')\n", + " plt.show()\n", + "\n", + " return photo_b64\n", " \n" ] },