summaryrefslogtreecommitdiff
path: root/getting-started-files
diff options
context:
space:
mode:
Diffstat (limited to 'getting-started-files')
-rw-r--r--getting-started-files/pendulum.txt90
-rw-r--r--getting-started-files/script.rst81
2 files changed, 149 insertions, 22 deletions
diff --git a/getting-started-files/pendulum.txt b/getting-started-files/pendulum.txt
new file mode 100644
index 0000000..7e07566
--- /dev/null
+++ b/getting-started-files/pendulum.txt
@@ -0,0 +1,90 @@
+1.0000e-01 6.9004e-01
+1.1000e-01 6.9497e-01
+1.2000e-01 7.4252e-01
+1.3000e-01 7.5360e-01
+1.4000e-01 8.3568e-01
+1.5000e-01 8.6789e-01
+1.6000e-01 8.4182e-01
+1.7000e-01 8.5379e-01
+1.8000e-01 8.5762e-01
+1.9000e-01 8.8390e-01
+2.0000e-01 8.9985e-01
+2.1000e-01 9.8436e-01
+2.2000e-01 1.0244e+00
+2.3000e-01 1.0572e+00
+2.4000e-01 9.9077e-01
+2.5000e-01 1.0058e+00
+2.6000e-01 1.0727e+00
+2.7000e-01 1.0943e+00
+2.8000e-01 1.1432e+00
+2.9000e-01 1.1045e+00
+3.0000e-01 1.1867e+00
+3.1000e-01 1.1385e+00
+3.2000e-01 1.2245e+00
+3.3000e-01 1.2406e+00
+3.4000e-01 1.2071e+00
+3.5000e-01 1.2658e+00
+3.6000e-01 1.2995e+00
+3.7000e-01 1.3142e+00
+3.8000e-01 1.2663e+00
+3.9000e-01 1.2578e+00
+4.0000e-01 1.2991e+00
+4.1000e-01 1.3058e+00
+4.2000e-01 1.3478e+00
+4.3000e-01 1.3506e+00
+4.4000e-01 1.4044e+00
+4.5000e-01 1.3948e+00
+4.6000e-01 1.3800e+00
+4.7000e-01 1.4480e+00
+4.8000e-01 1.4168e+00
+4.9000e-01 1.4719e+00
+5.0000e-01 1.4656e+00
+5.1000e-01 1.4399e+00
+5.2000e-01 1.5174e+00
+5.3000e-01 1.4988e+00
+5.4000e-01 1.4751e+00
+5.5000e-01 1.5326e+00
+5.6000e-01 1.5297e+00
+5.7000e-01 1.5372e+00
+5.8000e-01 1.6094e+00
+5.9000e-01 1.6352e+00
+6.0000e-01 1.5843e+00
+6.1000e-01 1.6643e+00
+6.2000e-01 1.5987e+00
+6.3000e-01 1.6585e+00
+6.4000e-01 1.6317e+00
+6.5000e-01 1.7074e+00
+6.6000e-01 1.6654e+00
+6.7000e-01 1.6551e+00
+6.8000e-01 1.6964e+00
+6.9000e-01 1.7143e+00
+7.0000e-01 1.7706e+00
+7.1000e-01 1.7622e+00
+7.2000e-01 1.7260e+00
+7.3000e-01 1.8089e+00
+7.4000e-01 1.7905e+00
+7.5000e-01 1.7428e+00
+7.6000e-01 1.8381e+00
+7.7000e-01 1.8182e+00
+7.8000e-01 1.7865e+00
+7.9000e-01 1.7995e+00
+8.0000e-01 1.8296e+00
+8.1000e-01 1.8625e+00
+8.2000e-01 1.8623e+00
+8.3000e-01 1.8383e+00
+8.4000e-01 1.8593e+00
+8.5000e-01 1.8944e+00
+8.6000e-01 1.9598e+00
+8.7000e-01 1.9000e+00
+8.8000e-01 1.9244e+00
+8.9000e-01 1.9397e+00
+9.0000e-01 1.9440e+00
+9.1000e-01 1.9718e+00
+9.2000e-01 1.9383e+00
+9.3000e-01 1.9555e+00
+9.4000e-01 2.0006e+00
+9.5000e-01 1.9841e+00
+9.6000e-01 2.0066e+00
+9.7000e-01 2.0493e+00
+9.8000e-01 2.0503e+00
+9.9000e-01 2.0214e+00
diff --git a/getting-started-files/script.rst b/getting-started-files/script.rst
index e090406..5c21dcc 100644
--- a/getting-started-files/script.rst
+++ b/getting-started-files/script.rst
@@ -1,10 +1,30 @@
-========
- Script
-========
+.. Objectives
+.. ----------
-Welcome to the tutorial on getting started with files.
+.. By the end of this tutorial, you will be able to
+.. 1. Open and read the contents of a file.
+.. #. Read files line by line.
+.. #. Read all the contents of the file at once.
+.. #. Close open files.
-{{{ Screen shows welcome slide }}}
+.. Prerequisites
+.. -------------
+
+.. 1. getting started with ipython
+.. #. getting started with lists
+.. #. getting started with for
+
+.. Author : Puneeth
+ Internal Reviewer :
+ External Reviewer :
+ Checklist OK? : <put date stamp here, if OK> [2010-10-05]
+
+Script
+------
+
+{{{ Show the slide containing title }}}
+
+Hello Friends. Welcome to the tutorial on getting started with files.
{{{ Show the outline for this tutorial }}}
@@ -33,7 +53,8 @@ see what it is.
f
The file object shows, the file which is open and the mode (read
-or write) in which it is open.
+or write) in which it is open. Notice that it is open in read only
+mode, here.
We shall first learn to read the whole file into a single
variable. Later, we shall look at reading it line-by-line. We use
@@ -54,24 +75,29 @@ to see more explicitly, what it contains.
pend
-%%1%% Pause the video here and split the variable into a list,
-``pend_list``, of the lines in the file and then resume the
-video. Hint, use the tab command to see what methods the string
-variable has.
+Following is an exercise that you must do.
+
+%%1%% Split the variable into a list, ``pend_list``, of the lines in
+the file. Hint, use the tab command to see what methods the string
+variable has.
+
+Please, pause the video here. Do the exercise and then continue.
+
+.. #[punch: should this even be put? add dependency to strings LO,
+.. where we mention that strings have methods for manipulation. hint:
+.. use splitlines()]
-#[punch: should this even be put? add dependency to strings LO,
-where we mention that strings have methods for manipulation. hint:
-use splitlines()]
::
pend_list = pend.splitlines()
pend_list
-Now, let us learn to read the file line-by-line. But, before that
-we will have to close the file, since the file has already been
-read till the end.
-#[punch: should we mention file-pointer?]
+Now, let us learn to read the file line-by-line. But, before that we
+will have to close the file, since the file has already been read till
+the end.
+
+.. #[punch: should we mention file-pointer?]
Let us close the file opened into f.
::
@@ -89,8 +115,11 @@ opened, after their job is done.
Let us, now move on to reading files line-by-line.
-%%1%% Pause the video here and re-open the file ``pendulum.txt``
-with ``f`` as the file object, and then resume the video.
+Following is an exercise that you must do.
+
+%%2%% Re-open the file ``pendulum.txt`` with ``f`` as the file object.
+
+Please, pause the video here. Do the exercise and then continue.
We just use the up arrow until we reach the open command and issue
it again.
@@ -123,8 +152,10 @@ file object ``f`` and directly open the file within the for
statement. This will save us the trouble of closing the file, each
time we open it.
-for line in open('/home/fossee/pendulum.txt'):
-line_list.append(line)
+::
+
+ for line in open('/home/fossee/pendulum.txt'):
+ line_list.append(line)
Let us see what ``line_list`` contains.
::
@@ -143,5 +174,11 @@ have learnt to open and close files, read the data in the files as
a whole, using the read command or reading it line by line by
iterating over the file object.
-Thank you!
+{{{ Show the "sponsored by FOSSEE" slide }}}
+
+This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
+
+Hope you have enjoyed and found it useful.
+Thank you!
+