Skip to content

Commit a23c166

Browse files
committed
add slide on reading plain text files
1 parent f739758 commit a23c166

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

extras/test_lectures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def num_slides_without_tag(cells, tag):
4141
return num_slides(tagged_cells)
4242

4343

44-
# see counts with `pytest -s -k num_slides`
44+
# see counts with `pytest -s -vv -k num_slides`
4545
@pytest.mark.parametrize("file", lecture_notebooks)
4646
def test_num_slides(file):
4747
"""Ensure there are a reasonable number of slides for each school"""

lecture_1.ipynb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
"cell_type": "code",
55
"execution_count": 1,
66
"metadata": {
7+
"editable": true,
78
"slideshow": {
89
"slide_type": "skip"
9-
}
10+
},
11+
"tags": []
1012
},
1113
"outputs": [],
1214
"source": [
@@ -119,6 +121,30 @@
119121
"https://docs.python.org/3/tutorial/modules.html"
120122
]
121123
},
124+
{
125+
"cell_type": "markdown",
126+
"metadata": {
127+
"editable": true,
128+
"slideshow": {
129+
"slide_type": "slide"
130+
},
131+
"tags": [
132+
"columbia-only"
133+
]
134+
},
135+
"source": [
136+
"## Working with files in Python\n",
137+
"\n",
138+
"We'll open the file, then read it row by row.\n",
139+
"\n",
140+
"```python\n",
141+
"# set up the file object\n",
142+
"with open(\"moby_dick.txt\") as file:\n",
143+
" for line in file:\n",
144+
" print(line)\n",
145+
"```"
146+
]
147+
},
122148
{
123149
"cell_type": "markdown",
124150
"metadata": {

0 commit comments

Comments
 (0)