{
 "cells": [
  {
   "cell_type": "code",
   "source": [
    "import pandas as pd\n",
    "import csv\n",
    "filename = 'Table_Réf_Professionnels_250815'\n",
    "df = pd.read_csv(\"E:\\\\Ziwig Drive\\\\Ziwig Health\\\\Tables de Réf\\\\Professionnels\\\\\"+filename+\".csv\", sep='|', doublequote=False, quoting=csv.QUOTE_NONE,dtype=str, na_values='', keep_default_na=False)\n",
    "df.columns"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2025-08-16T01:35:13.352289Z",
     "start_time": "2025-08-16T01:34:58.550068Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Type d'identifiant PP', 'Identifiant PP',\n",
       "       'Identification nationale PP', 'Code civilité d'exercice',\n",
       "       'Libellé civilité d'exercice', 'Code civilité', 'Libellé civilité',\n",
       "       'Nom d'exercice', 'Prénom d'exercice', 'Code profession',\n",
       "       'Libellé profession', 'Code catégorie professionnelle',\n",
       "       'Libellé catégorie professionnelle', 'Code type savoir-faire',\n",
       "       'Libellé type savoir-faire', 'Code savoir-faire',\n",
       "       'Libellé savoir-faire', 'Code mode exercice', 'Libellé mode exercice',\n",
       "       'Numéro SIRET site', 'Numéro SIREN site', 'Numéro FINESS site',\n",
       "       'Numéro FINESS établissement juridique',\n",
       "       'Identifiant technique de la structure', 'Raison sociale site',\n",
       "       'Enseigne commerciale site',\n",
       "       'Complément destinataire (coord. structure)',\n",
       "       'Complément point géographique (coord. structure)',\n",
       "       'Numéro Voie (coord. structure)',\n",
       "       'Indice répétition voie (coord. structure)',\n",
       "       'Code type de voie (coord. structure)',\n",
       "       'Libellé type de voie (coord. structure)',\n",
       "       'Libellé Voie (coord. structure)',\n",
       "       'Mention distribution (coord. structure)',\n",
       "       'Bureau cedex (coord. structure)', 'Code postal (coord. structure)',\n",
       "       'Code commune (coord. structure)', 'Libellé commune (coord. structure)',\n",
       "       'Code pays (coord. structure)', 'Libellé pays (coord. structure)',\n",
       "       'Téléphone (coord. structure)', 'Téléphone 2 (coord. structure)',\n",
       "       'Télécopie (coord. structure)', 'Adresse e-mail (coord. structure)',\n",
       "       'Code Département (structure)', 'Libellé Département (structure)',\n",
       "       'Ancien identifiant de la structure', 'Autorité d'enregistrement',\n",
       "       'Code secteur d'activité', 'Libellé secteur d'activité',\n",
       "       'Code section tableau pharmaciens',\n",
       "       'Libellé section tableau pharmaciens', 'Code rôle', 'Libellé rôle',\n",
       "       'Code genre activité', 'Libellé genre activité', 'Unnamed: 56'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "source": [
    "df.shape"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2025-08-16T01:35:13.450995Z",
     "start_time": "2025-08-16T01:35:13.442103Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(994582, 57)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "source": [
    "df_sorted = df.sort_values([\"Identifiant PP\", \"Nom d'exercice\", \"Prénom d'exercice\", 'Libellé profession', 'Libellé savoir-faire', 'Bureau cedex (coord. structure)', 'Numéro Voie (coord. structure)', 'Indice répétition voie (coord. structure)', 'Libellé type de voie (coord. structure)', 'Libellé Voie (coord. structure)' , 'Mention distribution (coord. structure)', 'Téléphone (coord. structure)'])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2025-08-16T01:35:20.312959Z",
     "start_time": "2025-08-16T01:35:13.656674Z"
    }
   },
   "outputs": [],
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "source": "df_sorted.to_csv(\"E:\\\\Ziwig Drive\\\\Ziwig Health\\\\Tables de Réf\\\\Professionnels\\\\\"+filename+\"-sorted.csv\", sep='|', index=False, doublequote=False, quoting=csv.QUOTE_NONE, lineterminator='\\n')",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2025-08-16T01:35:34.463854Z",
     "start_time": "2025-08-16T01:35:20.454076Z"
    }
   },
   "outputs": [],
   "execution_count": 4
  }
 ],
 "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.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
