Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
4a32fd8b6f5813775baefd9a2c62103b
mooc-rr
Commits
6fe851ac
Commit
6fe851ac
authored
Sep 02, 2020
by
4a32fd8b6f5813775baefd9a2c62103b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add stat computer for log files
parent
d83fb86e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
3 deletions
+103
-3
exercice.ipynb
module2/exo4/exercice.ipynb
+103
-3
No files found.
module2/exo4/exercice.ipynb
View file @
6fe851ac
{
"cells": [],
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# A notebook that gives stats on the notes taken so far\n",
"\n",
"## Useful functions\n",
"\n",
"First, let's define a function that counts how many sections there is in a *log file* : "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def count_sections(log_file):\n",
" with open(log_file, 'r') as fil: lines = fil.readlines()\n",
" s = 0\n",
" for line in lines : \n",
" if line[:1]=='# ': s += 1\n",
" return s"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Maybe I will add some other useful function later.\n",
"\n",
"Let's list all the *log files* :"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"There is 1 log file :\n",
"**Outils de prise de note :** \n",
"\n",
"\n",
"\n",
"- metalanguage Markdown\n",
"\n",
"- ReStructuredText for python\n",
"\n",
"\n",
"\n",
"**Organisation des données :**\n",
"\n",
"\n",
"\n",
"- TEI, est apparemment une sorte de norme permettant d'utiliser la même méthode de rangement de donnée même pour des dataset très différents\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"**Outils de gestion des fichier :**\n",
"\n",
"\n",
"\n",
"- docFetcher, pour chercher dans le contenu de plusieurs fichiers\n",
"\n",
"- exifttool, pour ajouter des metadonnées à un fichier\n",
"\n",
"\tmodule_1.md; contains 0 section.\n"
]
}
],
"source": [
"import os\n",
"\n",
"log_dir = '../../journal/'\n",
"ignored_files = ['Readme.md']\n",
"log_files = [fil for fil in os.listdir(log_dir) if fil not in ignored_files]\n",
"\n",
"if len(log_files)<2 : print(\"There is {:d} log file :\".format(len(log_files)))\n",
"else: print(\"There are {:d} log files :\".format(len(log_files)))\n",
" \n",
"for fil in log_files: \n",
" n_sec = count_sections(log_dir + fil)\n",
" if n_sec <2 : print(\"\\t{:}; contains {:d} section.\".format(fil, n_sec))\n",
" else: print(\"\\t{:}; contains {:d} sections.\".format(fil, n_sec))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
...
...
@@ -16,10 +117,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
4
"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment