author | anand |
Mon, 08 Nov 2010 01:36:47 +0530 | |
changeset 455 | f5b7d0b693d9 |
parent 274 | 1f8921b59ff0 |
permissions | -rw-r--r-- |
274
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
1 |
#+LaTeX_CLASS: beamer |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
2 |
#+LaTeX_CLASS_OPTIONS: [presentation] |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
3 |
#+BEAMER_FRAME_LEVEL: 1 |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
4 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
5 |
#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
6 |
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra) |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
7 |
#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
8 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
9 |
#+LaTeX_CLASS: beamer |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
10 |
#+LaTeX_CLASS_OPTIONS: [presentation] |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
11 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
12 |
#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
13 |
#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
14 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
15 |
#+LaTeX_HEADER: \usepackage{listings} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
16 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
17 |
#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries, |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
18 |
#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
19 |
#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
20 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
21 |
#+TITLE: Getting started with files |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
22 |
#+AUTHOR: FOSSEE |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
23 |
#+EMAIL: |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
24 |
#+DATE: |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
25 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
26 |
#+DESCRIPTION: |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
27 |
#+KEYWORDS: |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
28 |
#+LANGUAGE: en |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
29 |
#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
30 |
#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
31 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
32 |
* Outline |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
33 |
- Opening and reading contents of a file |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
34 |
- Closing open files |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
35 |
- Reading all the contents of the file at once |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
36 |
- Reading files line by line |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
37 |
* Question 1 |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
38 |
Split the variable into a list, =pend_list=, of the lines in the |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
39 |
file. Hint, use the tab command to see what methods the string |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
40 |
variable has. |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
41 |
* Solution 1 |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
42 |
#+begin_src python |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
43 |
In []: pend_list = pend.splitlines() |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
44 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
45 |
In []: pend_list |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
46 |
#+end_src |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
47 |
* Question 2 |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
48 |
Re-open the file =pendulum.txt= with =f= as the file object. |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
49 |
* Solution 2 |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
50 |
#+begin_src python |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
51 |
In []: f = open('/home/fossee/pendulum.txt') |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
52 |
#+end_src |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
53 |
* Summary |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
54 |
- Opening a file using =open= function |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
55 |
- Reading all the contents of the file at once using =read()= method |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
56 |
- Closing open files using the =close= method |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
57 |
- Reading files line by line by iterating using a =for= loop |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
58 |
* Thank you! |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
59 |
#+begin_latex |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
60 |
\begin{block}{} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
61 |
\begin{center} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
62 |
This spoken tutorial has been produced by the |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
63 |
\textcolor{blue}{FOSSEE} team, which is funded by the |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
64 |
\end{center} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
65 |
\begin{center} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
66 |
\textcolor{blue}{National Mission on Education through \\ |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
67 |
Information \& Communication Technology \\ |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
68 |
MHRD, Govt. of India}. |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
69 |
\end{center} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
70 |
\end{block} |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
71 |
#+end_latex |
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
72 |
|
1f8921b59ff0
Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
73 |