getting-started-files/quickref.tex
changeset 324 4054b1a6392d
parent 285 7c4855fb8e5f
equal deleted inserted replaced
323:e675f9208b91 324:4054b1a6392d
     1 Creating a linear array:\\
     1 \textbf{Getting Started -- files}
     2 {\ex \lstinline|    x = linspace(0, 2*pi, 50)|}
       
     3 
     2 
     4 Plotting two variables:\\
     3 \lstinline|f = open('filename')| returns a file object. \lstinline|f|
     5 {\ex \lstinline|    plot(x, sin(x))|}
     4 can be used to perform further operations on the file. 
     6 
     5 
     7 Plotting two lists of equal length x, y:\\
     6 \lstinline|f.read()| reads the whole file and returns the contents. 
     8 {\ex \lstinline|    plot(x, y)|}
     7 
       
     8 \lstinline|f.close()| closes the file. 
       
     9 
       
    10 \lstinline|for line in open('filename'):| -- iterate over the file
       
    11 line-by-line. 
       
    12