parsing_data/slides.org
changeset 280 40b6a90f41b7
equal deleted inserted replaced
279:5c9dc3419df5 280:40b6a90f41b7
       
     1 #+LaTeX_CLASS: beamer
       
     2 #+LaTeX_CLASS_OPTIONS: [presentation]
       
     3 #+BEAMER_FRAME_LEVEL: 1
       
     4 
       
     5 #+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
       
     6 #+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
       
     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
       
     8 
       
     9 #+LaTeX_CLASS: beamer
       
    10 #+LaTeX_CLASS_OPTIONS: [presentation]
       
    11 
       
    12 #+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
       
    13 #+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
       
    14 
       
    15 #+LaTeX_HEADER: \usepackage{listings}
       
    16 
       
    17 #+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
       
    18 #+LaTeX_HEADER:  commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
       
    19 #+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
       
    20 
       
    21 #+TITLE:    Parsing Data
       
    22 #+AUTHOR:    FOSSEE
       
    23 #+EMAIL:     
       
    24 #+DATE:    
       
    25 
       
    26 #+DESCRIPTION: 
       
    27 #+KEYWORDS: 
       
    28 #+LANGUAGE:  en
       
    29 #+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
       
    30 #+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
       
    31 
       
    32 * Outline
       
    33   - What is meant by parsing data? 
       
    34   - String operations required for parsing
       
    35   - Converting between data-types. 
       
    36 * Question 1
       
    37   Split the variable line using a space as argument. Is it same as
       
    38   splitting without an argument ?
       
    39 * Solution 1
       
    40   We see that when we split on space, multiple whitespaces are not
       
    41   clubbed as one and there is an empty string everytime there are two
       
    42   consecutive spaces.
       
    43 * Question 2
       
    44   What happens to the white space inside the sentence when it is
       
    45   stripped? 
       
    46 * Solution 2
       
    47   #+begin_src python
       
    48     In []: a_str = "     white      space     "
       
    49     In []: a_str.strip()
       
    50   #+end_src
       
    51 * Question 3
       
    52   What happens if you do =int("1.25")=
       
    53 * Solution 3
       
    54   It raises an error since converting a float string into integer
       
    55   directly is not possible. It involves an intermediate step of
       
    56   converting to float.
       
    57   #+begin_src python
       
    58     In []: dcml_str = "1.25"
       
    59     In []: flt = float(dcml_str)
       
    60     In []: flt
       
    61     In []: number = int(flt)
       
    62     In []: number
       
    63   #+end_src
       
    64 * Summary
       
    65   + How to tokenize a string using various delimiters
       
    66   + How to get rid of extra white space around
       
    67   + How to convert from one type to another
       
    68   + How to parse input data and perform computations on it
       
    69 * Thank you!
       
    70 #+begin_latex
       
    71   \begin{block}{}
       
    72   \begin{center}
       
    73   This spoken tutorial has been produced by the
       
    74   \textcolor{blue}{FOSSEE} team, which is funded by the 
       
    75   \end{center}
       
    76   \begin{center}
       
    77     \textcolor{blue}{National Mission on Education through \\
       
    78       Information \& Communication Technology \\ 
       
    79       MHRD, Govt. of India}.
       
    80   \end{center}  
       
    81   \end{block}
       
    82 #+end_latex
       
    83 
       
    84