File size: 21,687 Bytes
5067039
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2137907
5067039
 
 
 
2137907
 
5067039
 
 
 
2137907
5067039
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ecfe67d
5067039
 
ecfe67d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5067039
 
 
ecfe67d
5067039
 
ecfe67d
5067039
 
 
 
 
ecfe67d
 
5067039
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Defaulting to user installation because normal site-packages is not writeable\n",
      "Collecting lxml\n",
      "  Downloading lxml-4.9.3.tar.gz (3.6 MB)\n",
      "\u001b[K     |████████████████████████████████| 3.6 MB 3.0 MB/s eta 0:00:01\n",
      "\u001b[?25hBuilding wheels for collected packages: lxml\n",
      "  Building wheel for lxml (setup.py) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for lxml: filename=lxml-4.9.3-cp39-cp39-macosx_10_9_universal2.whl size=3109250 sha256=23007818bc62b33d4c6a6311fe35a09a7c0ad0b8150ed0a5b095f754a363c11e\n",
      "  Stored in directory: /Users/adrienbufort/Library/Caches/pip/wheels/5c/05/aa/530f84480d476c5bb9ea09877eea78fb144ec047fbb00ee2ca\n",
      "Successfully built lxml\n",
      "Installing collected packages: lxml\n",
      "Successfully installed lxml-4.9.3\n",
      "\u001b[33mWARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.\n",
      "You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip3 install lxml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "# import xml parsing tools\n",
    "import lxml.etree as ET\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 9 files\n",
      "Parsing Code de la consommation.xml\n",
      "Parsing Code civil.xml\n",
      "Parsing Code du travail.xml\n",
      "Parsing Code général des impôts.xml\n",
      "Parsing Code de la propriété intellectuelle.xml\n",
      "Parsing Code de la santé publique.xml\n",
      "Parsing Code de la sécurité sociale.xml\n",
      "Parsing Code pénal.xml\n",
      "Parsing Code de la route.xml\n"
     ]
    }
   ],
   "source": [
    "def retrieve_every_article_xml(xml_file):\n",
    "    \"\"\"\n",
    "    This function retrieves all the articles from a xml file\n",
    "    \"\"\"\n",
    "    tree = ET.parse(xml_file)\n",
    "    root = tree.getroot()\n",
    "    \n",
    "    # find all xml tags with the name \"article\"\n",
    "    articles = root.findall(\".//article\")\n",
    "    \n",
    "    # find all the parents of the articles\n",
    "    parents = [a.getparent() for a in articles]\n",
    "    \n",
    "    return articles, parents\n",
    "\n",
    "def parse_article_xml(article):\n",
    "    \n",
    "    # we we check if there is any children\n",
    "    return \"\".join(article.itertext())\n",
    "\n",
    "def main(main_folder=\"/Users/adrienbufort/Documents/workspace/datasets/LoiLibre/raw\"):\n",
    "    \n",
    "    # npw we can list all the xml files in the folder\n",
    "    import os\n",
    "    files = os.listdir(main_folder)\n",
    "    files = [f for f in files if f.endswith(\".xml\")]\n",
    "    print(\"Found {} files\".format(len(files)))\n",
    "    \n",
    "    # we can now parse all the files    \n",
    "    df_articles = []\n",
    "    \n",
    "    for f in files:\n",
    "        print(\"Parsing {}\".format(f))\n",
    "        articles, parents = retrieve_every_article_xml(os.path.join(main_folder, f))\n",
    "    \n",
    "        \n",
    "        articles_text = [parse_article_xml(a) for a in articles]\n",
    "        articles_metadata = [a.attrib for a in articles]\n",
    "        \n",
    "        title_parent = [p.attrib[\"title\"] for p in parents]\n",
    "        \n",
    "        dataframe_articles = pd.DataFrame({\"text\": articles_text, \"title_parent\": title_parent})\n",
    "        dataframe_metadata = pd.DataFrame(articles_metadata)\n",
    "        \n",
    "        # concatenate the columns\n",
    "        dataframe_tmp = pd.concat([dataframe_articles, dataframe_metadata], axis=1)\n",
    "        \n",
    "        # add the file name\n",
    "        dataframe_tmp[\"file_name\"] = f\n",
    "        \n",
    "        df_articles.append(dataframe_tmp)\n",
    "    \n",
    "    # concatenate all the dataframes\n",
    "    df_articles = pd.concat(df_articles)\n",
    "    \n",
    "    return df_articles\n",
    "\n",
    "# we can now parse all the files\n",
    "articles = main()\n",
    "    \n",
    "    \n",
    "    \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "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>text</th>\n",
       "      <th>title_parent</th>\n",
       "      <th>cid</th>\n",
       "      <th>date</th>\n",
       "      <th>etat</th>\n",
       "      <th>id</th>\n",
       "      <th>intOrdre</th>\n",
       "      <th>modId</th>\n",
       "      <th>modTitle</th>\n",
       "      <th>num</th>\n",
       "      <th>file_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>\\n      \\n       Pour l'application du présent...</td>\n",
       "      <td>Partie législative nouvelle</td>\n",
       "      <td>LEGIARTI000032228215</td>\n",
       "      <td>2021-12-23</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000044563103</td>\n",
       "      <td>1014089499</td>\n",
       "      <td>JORFTEXT000044546235</td>\n",
       "      <td>Ordonnance n°2021-1734 du 22 décembre 2021 - a...</td>\n",
       "      <td>liminaire</td>\n",
       "      <td>Code de la consommation.xml</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>\\n            Avant que le consommateur ne soi...</td>\n",
       "      <td>Chapitre Ier : Obligation générale d'informati...</td>\n",
       "      <td>LEGIARTI000032220903</td>\n",
       "      <td>2021-09-30</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000044142438</td>\n",
       "      <td>195225786</td>\n",
       "      <td>JORFTEXT000044125847</td>\n",
       "      <td>Ordonnance n°2021-1247 du 29 septembre 2021 - ...</td>\n",
       "      <td>L111-1</td>\n",
       "      <td>Code de la consommation.xml</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>\\n            Outre les mentions prévues à l'a...</td>\n",
       "      <td>Chapitre Ier : Obligation générale d'informati...</td>\n",
       "      <td>LEGIARTI000032220905</td>\n",
       "      <td>2016-03-16</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000032227350</td>\n",
       "      <td>390451572</td>\n",
       "      <td>JORFTEXT000032209352</td>\n",
       "      <td>Ordonnance n°2016-301 du 14 mars 2016 - art.</td>\n",
       "      <td>L111-2</td>\n",
       "      <td>Code de la consommation.xml</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>\\n            Les dispositions des articles L....</td>\n",
       "      <td>Chapitre Ier : Obligation générale d'informati...</td>\n",
       "      <td>LEGIARTI000032220907</td>\n",
       "      <td>2017-04-07</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000034388081</td>\n",
       "      <td>585677358</td>\n",
       "      <td>JORFTEXT000034379166</td>\n",
       "      <td>Ordonnance n°2017-484 du 6 avril 2017 - art. 17</td>\n",
       "      <td>L111-3</td>\n",
       "      <td>Code de la consommation.xml</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>\\n            Le fabricant ou l'importateur de...</td>\n",
       "      <td>Chapitre Ier : Obligation générale d'informati...</td>\n",
       "      <td>LEGIARTI000032220909</td>\n",
       "      <td>2021-11-16</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000044330854</td>\n",
       "      <td>780903144</td>\n",
       "      <td>JORFTEXT000044327272</td>\n",
       "      <td>LOI n°2021-1485 du 15 novembre 2021 - art. 18</td>\n",
       "      <td>L111-4</td>\n",
       "      <td>Code de la consommation.xml</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",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1152</th>\n",
       "      <td>\\n            I.- Lorsque ces informations son...</td>\n",
       "      <td>Chapitre 1er : Responsabilité pénale</td>\n",
       "      <td>LEGIARTI000033668477</td>\n",
       "      <td>2021-10-21</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000044233123</td>\n",
       "      <td>1879048191</td>\n",
       "      <td>JORFTEXT000044229080</td>\n",
       "      <td>Arrêté du 13 octobre 2021 - art. 5</td>\n",
       "      <td>A121-3</td>\n",
       "      <td>Code de la route.xml</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1153</th>\n",
       "      <td>\\n            Sont applicables en Nouvelle-Cal...</td>\n",
       "      <td>Chapitre 3 : Dispositions applicables en Nouve...</td>\n",
       "      <td>LEGIARTI000033668491</td>\n",
       "      <td>2021-10-21</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000044233128</td>\n",
       "      <td>1073741823</td>\n",
       "      <td>JORFTEXT000044229080</td>\n",
       "      <td>Arrêté du 13 octobre 2021 - art. 6</td>\n",
       "      <td>A143-1</td>\n",
       "      <td>Code de la route.xml</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1154</th>\n",
       "      <td>\\n                Le modèle de fiche descripti...</td>\n",
       "      <td>Sous-section 1 : Dispositions générales</td>\n",
       "      <td>LEGIARTI000042522938</td>\n",
       "      <td>2023-06-11</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000047666753</td>\n",
       "      <td>1073741823</td>\n",
       "      <td>JORFTEXT000047664460</td>\n",
       "      <td>Arrêté du 9 juin 2023 - art. 1</td>\n",
       "      <td>A325-12</td>\n",
       "      <td>Code de la route.xml</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1155</th>\n",
       "      <td>\\n                Les données relatives à l'en...</td>\n",
       "      <td>Sous-section 1 : Dispositions générales</td>\n",
       "      <td>LEGIARTI000042522940</td>\n",
       "      <td>2021-03-28</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000043308615</td>\n",
       "      <td>1610612735</td>\n",
       "      <td>JORFTEXT000043297189</td>\n",
       "      <td>Arrêté du 15 mars 2021 - art. 1</td>\n",
       "      <td>A325-13</td>\n",
       "      <td>Code de la route.xml</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1156</th>\n",
       "      <td>\\n                Le délai prévu au quatrième ...</td>\n",
       "      <td>Sous-section 1 : Dispositions générales</td>\n",
       "      <td>LEGIARTI000042522942</td>\n",
       "      <td>2022-06-18</td>\n",
       "      <td>VIGUEUR</td>\n",
       "      <td>LEGIARTI000045936067</td>\n",
       "      <td>1879048191</td>\n",
       "      <td>JORFTEXT000045930087</td>\n",
       "      <td>Arrêté du 10 juin 2022 - art. 1</td>\n",
       "      <td>A325-14</td>\n",
       "      <td>Code de la route.xml</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>43534 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                   text  \\\n",
       "0     \\n      \\n       Pour l'application du présent...   \n",
       "1     \\n            Avant que le consommateur ne soi...   \n",
       "2     \\n            Outre les mentions prévues à l'a...   \n",
       "3     \\n            Les dispositions des articles L....   \n",
       "4     \\n            Le fabricant ou l'importateur de...   \n",
       "...                                                 ...   \n",
       "1152  \\n            I.- Lorsque ces informations son...   \n",
       "1153  \\n            Sont applicables en Nouvelle-Cal...   \n",
       "1154  \\n                Le modèle de fiche descripti...   \n",
       "1155  \\n                Les données relatives à l'en...   \n",
       "1156  \\n                Le délai prévu au quatrième ...   \n",
       "\n",
       "                                           title_parent                   cid  \\\n",
       "0                           Partie législative nouvelle  LEGIARTI000032228215   \n",
       "1     Chapitre Ier : Obligation générale d'informati...  LEGIARTI000032220903   \n",
       "2     Chapitre Ier : Obligation générale d'informati...  LEGIARTI000032220905   \n",
       "3     Chapitre Ier : Obligation générale d'informati...  LEGIARTI000032220907   \n",
       "4     Chapitre Ier : Obligation générale d'informati...  LEGIARTI000032220909   \n",
       "...                                                 ...                   ...   \n",
       "1152               Chapitre 1er : Responsabilité pénale  LEGIARTI000033668477   \n",
       "1153  Chapitre 3 : Dispositions applicables en Nouve...  LEGIARTI000033668491   \n",
       "1154           Sous-section 1 : Dispositions générales   LEGIARTI000042522938   \n",
       "1155           Sous-section 1 : Dispositions générales   LEGIARTI000042522940   \n",
       "1156           Sous-section 1 : Dispositions générales   LEGIARTI000042522942   \n",
       "\n",
       "            date     etat                    id    intOrdre  \\\n",
       "0     2021-12-23  VIGUEUR  LEGIARTI000044563103  1014089499   \n",
       "1     2021-09-30  VIGUEUR  LEGIARTI000044142438   195225786   \n",
       "2     2016-03-16  VIGUEUR  LEGIARTI000032227350   390451572   \n",
       "3     2017-04-07  VIGUEUR  LEGIARTI000034388081   585677358   \n",
       "4     2021-11-16  VIGUEUR  LEGIARTI000044330854   780903144   \n",
       "...          ...      ...                   ...         ...   \n",
       "1152  2021-10-21  VIGUEUR  LEGIARTI000044233123  1879048191   \n",
       "1153  2021-10-21  VIGUEUR  LEGIARTI000044233128  1073741823   \n",
       "1154  2023-06-11  VIGUEUR  LEGIARTI000047666753  1073741823   \n",
       "1155  2021-03-28  VIGUEUR  LEGIARTI000043308615  1610612735   \n",
       "1156  2022-06-18  VIGUEUR  LEGIARTI000045936067  1879048191   \n",
       "\n",
       "                     modId                                           modTitle  \\\n",
       "0     JORFTEXT000044546235  Ordonnance n°2021-1734 du 22 décembre 2021 - a...   \n",
       "1     JORFTEXT000044125847  Ordonnance n°2021-1247 du 29 septembre 2021 - ...   \n",
       "2     JORFTEXT000032209352       Ordonnance n°2016-301 du 14 mars 2016 - art.   \n",
       "3     JORFTEXT000034379166    Ordonnance n°2017-484 du 6 avril 2017 - art. 17   \n",
       "4     JORFTEXT000044327272      LOI n°2021-1485 du 15 novembre 2021 - art. 18   \n",
       "...                    ...                                                ...   \n",
       "1152  JORFTEXT000044229080                 Arrêté du 13 octobre 2021 - art. 5   \n",
       "1153  JORFTEXT000044229080                 Arrêté du 13 octobre 2021 - art. 6   \n",
       "1154  JORFTEXT000047664460                     Arrêté du 9 juin 2023 - art. 1   \n",
       "1155  JORFTEXT000043297189                    Arrêté du 15 mars 2021 - art. 1   \n",
       "1156  JORFTEXT000045930087                    Arrêté du 10 juin 2022 - art. 1   \n",
       "\n",
       "            num                    file_name  \n",
       "0     liminaire  Code de la consommation.xml  \n",
       "1        L111-1  Code de la consommation.xml  \n",
       "2        L111-2  Code de la consommation.xml  \n",
       "3        L111-3  Code de la consommation.xml  \n",
       "4        L111-4  Code de la consommation.xml  \n",
       "...         ...                          ...  \n",
       "1152     A121-3         Code de la route.xml  \n",
       "1153     A143-1         Code de la route.xml  \n",
       "1154    A325-12         Code de la route.xml  \n",
       "1155    A325-13         Code de la route.xml  \n",
       "1156    A325-14         Code de la route.xml  \n",
       "\n",
       "[43534 rows x 11 columns]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get parent\n",
    "articles"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "# strip the text\n",
    "articles[\"text\"] = articles[\"text\"].str.strip()\n",
    "articles[\"file_name\"] = articles[\"file_name\"].str[:-4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "# save the dataframe\n",
    "articles.to_parquet(\"../articles.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Defaulting to user installation because normal site-packages is not writeable\n",
      "Collecting pyarrow\n",
      "  Downloading pyarrow-14.0.1-cp39-cp39-macosx_11_0_arm64.whl (24.0 MB)\n",
      "\u001b[K     |████████████████████████████████| 24.0 MB 14.7 MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: numpy>=1.16.6 in /Users/adrienbufort/Library/Python/3.9/lib/python/site-packages (from pyarrow) (1.25.1)\n",
      "Installing collected packages: pyarrow\n",
      "Successfully installed pyarrow-14.0.1\n",
      "\u001b[33mWARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.\n",
      "You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "text            Par dérogation à l'article 167 du code de proc...\n",
      "title_parent                           Sous-section 9 : Expertise\n",
      "cid                                          LEGIARTI000032223139\n",
      "date                                                   2016-03-16\n",
      "etat                                                      VIGUEUR\n",
      "id                                           LEGIARTI000032225017\n",
      "intOrdre                                               1789569700\n",
      "modId                                        JORFTEXT000032209352\n",
      "modTitle             Ordonnance n°2016-301 du 14 mars 2016 - art.\n",
      "num                                                       L512-48\n",
      "file_name                                 Code de la consommation\n",
      "Name: 1000, dtype: object\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"Par dérogation à l'article 167 du code de procédure pénale, si les experts sont en désaccord, ou s'ils sont d'accord pour infirmer les conclusions du rapport du laboratoire d'Etat, le procureur de la République ou la juridiction, avant de statuer, donne à ce laboratoire connaissance du rapport d'expertise et lui fixe un délai pour faire parvenir éventuellement ses observations, sauf dans le cas où le directeur du laboratoire intéressé a participé lui-même à l'expertise en qualité d'expert.\""
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(articles.iloc[1000])\n",
    "articles.iloc[1000].text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}