{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "62188aef",
   "metadata": {},
   "outputs": [],
   "source": [
    "list_complete = ''\n",
    "list_pending = ''\n",
    "title = ''\n",
    "perc = ('80', '40', '۸۰٪')\n",
    "description = ''\n",
    "comment = ''\n",
    "link = ''\n",
    "link_ref = ''\n",
    "\n",
    "def get_html(list_complete, list_pending, title, perc, description, comment, link, link_ref):\n",
    "\n",
    "    completed_tasks = ''\n",
    "    for i in list_complete:\n",
    "        completed_tasks += '<li>' + i +'</li>'\n",
    "\n",
    "    pending_task = ''\n",
    "    for i in list_pending:\n",
    "        pending_task += '<li>' + i +'</li>'\n",
    "\n",
    "\n",
    "\n",
    "    html_1 = \"\"\"\n",
    "                <div class=\"col-md-6 col-lg-4\">\n",
    "                    <div class=\"card project-card\">\n",
    "                        <div class=\"card-body\">\n",
    "                            <h5 class=\"h4 mb-3\">\"\"\"+ title + '</h5> <p class=\"card-text\">'\n",
    "\n",
    "    html_1 += description\n",
    "    html_1 += ' </p><div class=\"container text-center justify-content: center\">وضعیت پیشرفت '\n",
    "    html_1 += '<div class=\"progress-container\"><div class=\"progress\" style=\"width:' + perc[0] + '%; padding-right: ' + perc[1] + '%;\">' +perc[2]\n",
    "    html_1 += '</div></div></div><p>'\n",
    "\n",
    "    if len(completed_tasks)>0:\n",
    "        html_1 +='<ul style=\"list-style-type: \\'✅ \\' ;\">' + completed_tasks + '</ul>'\n",
    "\n",
    "    if len(pending_task)>0:\n",
    "        html_1 +='<ul style=\"list-style-type: \\'⏳ \\' ;\">' + pending_task + '</ul>'\n",
    "    html_1 += '</p>'\n",
    "    if type(comment)==str:\n",
    "        html_1 += str(comment)\n",
    "\n",
    "    if type(link)==str:\n",
    "        html_1 += '<a href=\"' + str(link) + '\">'\n",
    "        if type(link_ref)==str:\n",
    "            html_1 += '<p class=\"card-text\">' + str(link_ref) + '</p>'\n",
    "        else:\n",
    "            html_1 += '<p class=\"card-text\">آدرس</p>'\n",
    "        html_1 += '</a>'\n",
    "\n",
    "    html_1 += \"\"\"</div></div></div> \n",
    "    <!-- Repeat for other projects -->\"\"\"\n",
    "    return html_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ccb7eed8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "#csv_file_path = 'proj_data_ex.xlsx'\n",
    "#csv_file_path = 'distributed_ai.xlsx'\n",
    "#csv_file_path = 'questionner.xlsx'\n",
    "csv_file_path = 'fairness.xlsx'\n",
    "\n",
    "xls = pd.read_excel(csv_file_path, sheet_name=None, engine='openpyxl')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "762b688a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "                <div class=\"col-md-6 col-lg-4\">\n",
      "                    <div class=\"card project-card\">\n",
      "                        <div class=\"card-body\">\n",
      "                            <h5 class=\"h4 mb-3\">انصاف در اثرگذاری</h5> <p class=\"card-text\">روش متفاوتی ربای معیار سنجی انصاف مدل بر اساس میزان تاثیر کلی هر داده (یا گروه داده) بر روی تصمیمات مدل. </p><div class=\"container text-center justify-content: center\">وضعیت پیشرفت <div class=\"progress-container\"><div class=\"progress\" style=\"width:40%; padding-right: 20%;\">۴۰٪</div></div></div><p><ul style=\"list-style-type: '✅ ' ;\"><li>تخمین سهم تاثیر داده‌ها</li><li>محاسبه تاثیر کناری برای دسته‌های مختلف داده</li></ul><ul style=\"list-style-type: '⏳ ' ;\"><li>دسته‌بندی روش‌های متفاوت برای نسبت سنجی تاثیر</li><li>مقایسه‌ی شرایط منصفانه و غیر منصفانه</li><li>مقایسه‌ی کیفی شرایط تشخیص با روش‌های کنونی</li><li>اعمال شرط انصاف در آموزش مدل</li></ul></p></div></div></div> \n",
      "    <!-- Repeat for other projects -->\n"
     ]
    }
   ],
   "source": [
    "percentages = [('10', '2', '۰٪'),\n",
    "              ('15', '5', '۱۰٪'),\n",
    "              ('20', '10', '۲۰٪'),\n",
    "              ('30', '15', '۳۰٪'),\n",
    "              ('40', '20', '۴۰٪'),\n",
    "              ('50', '25', '۵۰٪'),\n",
    "              ('60', '30', '۶۰٪'),\n",
    "              ('70', '35', '۸۰٪'),\n",
    "              ('80', '40', '۸۰٪'),\n",
    "              ('90', '45', '۹۰٪'),\n",
    "              ('100', '50', '۱۰۰٪')]\n",
    "for sheet_name, df in xls.items():\n",
    "    cols = df.columns\n",
    "    title = df[df.columns[0]][0]\n",
    "    description = df[df.columns[1]][0]\n",
    "    p = int(df[df.columns[2]][0])\n",
    "    perc = percentages[p]\n",
    "    list_complete = df[df.columns[3]].dropna()\n",
    "    list_pending = df[df.columns[4]].dropna()\n",
    "    comment = df[df.columns[5]].dropna()\n",
    "    link = df[df.columns[6]][0]\n",
    "    link_ref = df[df.columns[7]][0]\n",
    "\n",
    "    h = get_html(list_complete, list_pending, title, perc, description, comment, link, link_ref)\n",
    "    print(h)\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "id": "91b185fb",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "object of type 'numpy.float64' has no len()",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0mTraceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_37900/3929354373.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlink\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: object of type 'numpy.float64' has no len()"
     ]
    }
   ],
   "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.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
