getting-started-files/slides.tex
author Nishanth <nishanth@fossee.in>
Mon, 11 Oct 2010 13:42:52 +0530
changeset 297 bef342784a40
parent 274 1f8921b59ff0
child 345 d82151cc11f5
permissions -rw-r--r--
removed redundant scripts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     1
% Created 2010-10-10 Sun 17:51
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     2
\documentclass[presentation]{beamer}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
\usepackage[latin1]{inputenc}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
\usepackage[T1]{fontenc}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     5
\usepackage{fixltx2e}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     6
\usepackage{graphicx}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     7
\usepackage{longtable}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     8
\usepackage{float}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     9
\usepackage{wrapfig}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    10
\usepackage{soul}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    11
\usepackage{textcomp}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    12
\usepackage{marvosym}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    13
\usepackage{wasysym}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    14
\usepackage{latexsym}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    15
\usepackage{amssymb}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    16
\usepackage{hyperref}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    17
\tolerance=1000
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    18
\usepackage[english]{babel} \usepackage{ae,aecompl}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    19
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    20
\usepackage{listings}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    21
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    22
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    23
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    24
\providecommand{\alert}[1]{\textbf{#1}}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    26
\title{Getting started with files}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    27
\author{FOSSEE}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    28
\date{}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    30
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    31
\begin{document}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    33
\maketitle
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    34
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    35
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    36
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    37
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    38
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    39
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    40
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    41
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    42
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    43
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    44
\begin{frame}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    45
\frametitle{Outline}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    46
\label{sec-1}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    47
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    48
\begin{itemize}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    49
\item Opening and reading contents of a file
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    50
\item Closing open files
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    51
\item Reading all the contents of the file at once
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    52
\item Reading files line by line
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    53
\end{itemize}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    54
\end{frame}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    55
\begin{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    56
\frametitle{Question 1}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    57
\label{sec-2}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    58
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    59
  Split the variable into a list, \texttt{pend\_list}, of the lines in the
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    60
  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: 217
diff changeset
    61
  variable has.
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    62
\end{frame}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    63
\begin{frame}[fragile]
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    64
\frametitle{Solution 1}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    65
\label{sec-3}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    66
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    67
\lstset{language=Python}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    68
\begin{lstlisting}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    69
In []: pend_list = pend.splitlines()
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    70
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    71
In []: pend_list
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    72
\end{lstlisting}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    73
\end{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    74
\begin{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    75
\frametitle{Question 2}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    76
\label{sec-4}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    77
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    78
  Re-open the file \texttt{pendulum.txt} with \texttt{f} as the file object.
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    79
\end{frame}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    80
\begin{frame}[fragile]
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    81
\frametitle{Solution 2}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    82
\label{sec-5}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    83
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    84
\lstset{language=Python}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    85
\begin{lstlisting}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    86
In []:   f = open('/home/fossee/pendulum.txt')
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    87
\end{lstlisting}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    88
\end{frame}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    89
\begin{frame}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    90
\frametitle{Summary}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    91
\label{sec-6}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    92
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    93
\begin{itemize}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    94
\item Opening a file using \texttt{open} function
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    95
\item Reading all the contents of the file at once using \texttt{read()} method
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    96
\item Closing open files using the \texttt{close} method
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    97
\item Reading files line by line by iterating using a \texttt{for} loop
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    98
\end{itemize}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    99
\end{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   100
\begin{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   101
\frametitle{Thank you!}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   102
\label{sec-7}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   103
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   104
  \begin{block}{}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   105
  \begin{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   106
  This spoken tutorial has been produced by the
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   107
  \textcolor{blue}{FOSSEE} team, which is funded by the 
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   108
  \end{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   109
  \begin{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   110
    \textcolor{blue}{National Mission on Education through \\
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   111
      Information \& Communication Technology \\ 
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   112
      MHRD, Govt. of India}.
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   113
  \end{center}  
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   114
  \end{block}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   115
\end{frame}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   116
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   117
\end{document}