diff -r 55342d3c9d25 -r 7c4855fb8e5f getting-started-files/quickref.tex --- a/getting-started-files/quickref.tex Mon Oct 11 01:25:45 2010 +0530 +++ b/getting-started-files/quickref.tex Mon Oct 11 11:40:04 2010 +0530 @@ -1,8 +1,12 @@ -Creating a linear array:\\ -{\ex \lstinline| x = linspace(0, 2*pi, 50)|} +\textbf{Getting Started -- files} + +\lstinline|f = open('filename')| returns a file object. \lstinline|f| +can be used to perform further operations on the file. -Plotting two variables:\\ -{\ex \lstinline| plot(x, sin(x))|} +\lstinline|f.read()| reads the whole file and returns the contents. + +\lstinline|f.close()| closes the file. -Plotting two lists of equal length x, y:\\ -{\ex \lstinline| plot(x, y)|} +\lstinline|for line in open('filename'):| -- iterate over the file +line-by-line. +