Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
61 changes: 40 additions & 21 deletions file-io.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -43,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -70,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -99,7 +99,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -108,7 +108,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -119,20 +119,9 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<generator object Path.glob at 0x71ead4273450>"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from pathlib import Path\n",
"\n",
Expand All @@ -146,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -155,6 +144,36 @@
" with open(iliad_file, \"r\") as f:\n",
" a.write(f.read() + \"\\n\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Homework:\n",
"\n",
"In order to finish the lab, you will need to `open` the file `pope-iliad.txt`, which I have added to the repository.\n",
"\n",
"Take any slice of 1000 lines (remember how to use the slice operator? How do you split lines in a string?), and write them to individual files in a directory that you have created.\n",
"\n",
"Then open a pull request with the results."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"with open('pope-iliad.txt', 'r') as f:\n",
" lines = f.read().splitlines()[2000:3000]\n",
"\n",
"if not Path(\"hw_IO\").exists():\n",
" Path(\"hw_IO\").mkdir()\n",
"\n",
"for i in range(len(lines)):\n",
" with open(Path(\"hw_IO\")/f'hw-iliad{i}.txt', \"w\") as f:\n",
" f.write(lines[i])"
]
}
],
"metadata": {
Expand Down
1 change: 1 addition & 0 deletions hw_IO/hw-iliad0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I could say a great deal of the pleasure of being distinguished by the
1 change: 1 addition & 0 deletions hw_IO/hw-iliad1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Earl of Carnarvon; but it is almost absurd to particularize any one
1 change: 1 addition & 0 deletions hw_IO/hw-iliad10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
no way better oblige men of their turn than by my silence.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad100.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And dread avenging Phœbus, son of Jove.”
Empty file added hw_IO/hw-iliad101.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad102.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Greeks in shouts their joint assent declare,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad103.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The priest to reverence, and release the fair.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad104.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Not so Atrides; he, with kingly pride,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad105.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Repulsed the sacred sire, and thus replied:
1 change: 1 addition & 0 deletions hw_IO/hw-iliad106.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
“Hence on thy life, and fly these hostile plains,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad107.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Nor ask, presumptuous, what the king detains:
Empty file added hw_IO/hw-iliad108.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad109.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hence, with thy laurel crown, and golden rod,
Empty file added hw_IO/hw-iliad11.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad110.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Nor trust too far those ensigns of thy god.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad111.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mine is thy daughter, priest, and shall remain;
1 change: 1 addition & 0 deletions hw_IO/hw-iliad112.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And prayers, and tears, and bribes, shall plead in vain;
1 change: 1 addition & 0 deletions hw_IO/hw-iliad113.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Till time shall rifle every youthful grace,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad114.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And age dismiss her from my cold embrace,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad115.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In daily labours of the loom employ’d,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad116.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Or doom’d to deck the bed she once enjoy’d.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad117.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hence then; to Argos shall the maid retire,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad118.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Far from her native soil and weeping sire.”
Empty file added hw_IO/hw-iliad119.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad12.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In short, I have found more patrons than ever Homer wanted. He would
Empty file added hw_IO/hw-iliad120.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad121.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Illustration: ] HOMER INVOKING THE MUSE
Empty file added hw_IO/hw-iliad122.txt
Empty file.
Empty file added hw_IO/hw-iliad123.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad124.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The trembling priest along the shore return’d,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad125.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And in the anguish of a father mourn’d.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad126.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disconsolate, not daring to complain,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad127.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Silent he wander’d by the sounding main;
1 change: 1 addition & 0 deletions hw_IO/hw-iliad128.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Till, safe at distance, to his god he prays,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad129.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The god who darts around the world his rays.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
have thought himself happy to have met the same favour at Athens that
Empty file added hw_IO/hw-iliad130.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad131.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
“O Smintheus! sprung from fair Latona’s line,[47]
1 change: 1 addition & 0 deletions hw_IO/hw-iliad132.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Thou guardian power of Cilla the divine,[48]
1 change: 1 addition & 0 deletions hw_IO/hw-iliad133.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Thou source of light! whom Tenedos adores,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad134.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And whose bright presence gilds thy Chrysa’s shores.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad135.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If e’er with wreaths I hung thy sacred fane,[49]
1 change: 1 addition & 0 deletions hw_IO/hw-iliad136.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Or fed the flames with fat of oxen slain;
1 change: 1 addition & 0 deletions hw_IO/hw-iliad137.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
God of the silver bow! thy shafts employ,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad138.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avenge thy servant, and the Greeks destroy.”
Empty file added hw_IO/hw-iliad139.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad14.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
has been shown me by its learned rival, the University of Oxford. And I
1 change: 1 addition & 0 deletions hw_IO/hw-iliad140.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Thus Chryses pray’d:—the favouring power attends,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad141.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And from Olympus’ lofty tops descends.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad142.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bent was his bow, the Grecian hearts to wound;[50]
1 change: 1 addition & 0 deletions hw_IO/hw-iliad143.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fierce as he moved, his silver shafts resound.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad144.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Breathing revenge, a sudden night he spread,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad145.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And gloomy darkness roll’d about his head.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad146.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The fleet in view, he twang’d his deadly bow,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad147.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And hissing fly the feather’d fates below.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad148.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On mules and dogs the infection first began;[51]
1 change: 1 addition & 0 deletions hw_IO/hw-iliad149.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And last, the vengeful arrows fix’d in man.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad15.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
can hardly envy him those pompous honours he received after death, when
1 change: 1 addition & 0 deletions hw_IO/hw-iliad150.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For nine long nights, through all the dusky air,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad151.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The pyres, thick-flaming, shot a dismal glare.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad152.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
But ere the tenth revolving day was run,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad153.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inspired by Juno, Thetis’ godlike son
1 change: 1 addition & 0 deletions hw_IO/hw-iliad154.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convened to council all the Grecian train;
1 change: 1 addition & 0 deletions hw_IO/hw-iliad155.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For much the goddess mourn’d her heroes slain.[52]
1 change: 1 addition & 0 deletions hw_IO/hw-iliad156.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The assembly seated, rising o’er the rest,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad157.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Achilles thus the king of men address’d:
Empty file added hw_IO/hw-iliad158.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad159.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
“Why leave we not the fatal Trojan shore,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad16.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I reflect on the enjoyment of so many agreeable obligations, and easy
1 change: 1 addition & 0 deletions hw_IO/hw-iliad160.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And measure back the seas we cross’d before?
1 change: 1 addition & 0 deletions hw_IO/hw-iliad161.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The plague destroying whom the sword would spare,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad162.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
’Tis time to save the few remains of war.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad163.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
But let some prophet, or some sacred sage,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad164.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Explore the cause of great Apollo’s rage;
1 change: 1 addition & 0 deletions hw_IO/hw-iliad165.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Or learn the wasteful vengeance to remove
1 change: 1 addition & 0 deletions hw_IO/hw-iliad166.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
By mystic dreams, for dreams descend from Jove.[53]
1 change: 1 addition & 0 deletions hw_IO/hw-iliad167.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If broken vows this heavy curse have laid,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad168.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Let altars smoke, and hecatombs be paid.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad169.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
So Heaven, atoned, shall dying Greece restore,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad17.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
friendships, which make the satisfaction of life. This distinction is
1 change: 1 addition & 0 deletions hw_IO/hw-iliad170.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And Phœbus dart his burning shafts no more.”
Empty file added hw_IO/hw-iliad171.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad172.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
He said, and sat: when Chalcas thus replied;
1 change: 1 addition & 0 deletions hw_IO/hw-iliad173.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Chalcas the wise, the Grecian priest and guide,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad174.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
That sacred seer, whose comprehensive view,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad175.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The past, the present, and the future knew:
1 change: 1 addition & 0 deletions hw_IO/hw-iliad176.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Uprising slow, the venerable sage
1 change: 1 addition & 0 deletions hw_IO/hw-iliad177.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Thus spoke the prudence and the fears of age:
Empty file added hw_IO/hw-iliad178.txt
Empty file.
1 change: 1 addition & 0 deletions hw_IO/hw-iliad179.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
“Beloved of Jove, Achilles! would’st thou know
1 change: 1 addition & 0 deletions hw_IO/hw-iliad18.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
the more to be acknowledged, as it is shown to one whose pen has never
1 change: 1 addition & 0 deletions hw_IO/hw-iliad180.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Why angry Phœbus bends his fatal bow?
1 change: 1 addition & 0 deletions hw_IO/hw-iliad181.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
First give thy faith, and plight a prince’s word
1 change: 1 addition & 0 deletions hw_IO/hw-iliad182.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Of sure protection, by thy power and sword:
1 change: 1 addition & 0 deletions hw_IO/hw-iliad183.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For I must speak what wisdom would conceal,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad184.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And truths, invidious to the great, reveal,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad185.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bold is the task, when subjects, grown too wise,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad186.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Instruct a monarch where his error lies;
1 change: 1 addition & 0 deletions hw_IO/hw-iliad187.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For though we deem the short-lived fury past,
1 change: 1 addition & 0 deletions hw_IO/hw-iliad188.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
’Tis sure the mighty will revenge at last.”
1 change: 1 addition & 0 deletions hw_IO/hw-iliad189.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
To whom Pelides:—“From thy inmost soul
Loading