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
edb84ce5
Commit
edb84ce5
authored
Sep 02, 2020
by
schd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweek stat computer
parent
91aba9f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
12 deletions
+123
-12
exercice-checkpoint.ipynb
module2/exo4/.ipynb_checkpoints/exercice-checkpoint.ipynb
+118
-0
exercice.ipynb
module2/exo4/exercice.ipynb
+5
-12
No files found.
module2/exo4/.ipynb_checkpoints/exercice-checkpoint.ipynb
0 → 100644
View file @
edb84ce5
{
"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": 11,
"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",
" print(line[:2])\n",
" if line[:2]==' # ': 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": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"There is 1 log file :\n",
"# \n",
"\n",
"\n",
"- \n",
"- \n",
"\n",
"\n",
"# \n",
"\n",
"\n",
"- \n",
"\n",
"\n",
"\n",
"\n",
"# \n",
"\n",
"\n",
"- \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",
"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.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
module2/exo4/exercice.ipynb
View file @
edb84ce5
...
...
@@ -13,7 +13,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count":
2
1,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -21,7 +21,7 @@
" 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",
" if line[:
2
]=='# ': s += 1\n",
" return s"
]
},
...
...
@@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 2
2
,
"metadata": {},
"outputs": [
{
...
...
@@ -44,7 +44,7 @@
"output_type": "stream",
"text": [
"There is 1 log file :\n",
"\tmodule_1.md; contains
0 section
.\n"
"\tmodule_1.md; contains
3 sections
.\n"
]
}
],
...
...
@@ -64,13 +64,6 @@
" else: print(\"\\t{:}; contains {:d} sections.\".format(fil, n_sec))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
...
...
@@ -89,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
4
"
"version": "3.6.
9
"
}
},
"nbformat": 4,
...
...
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