In [2]:
def readlinebyline( filename ) :
'''This function takes in a textfile, and reads line by line
and prints to stdout.'''
f = open(filename,'r')
for line in f :
print line
f.close()
In [6]:
from print_line_by_line import readlinebyline
In [12]:
# The glob object
from glob import glob
In [18]:
glob('data*.txt')
Out[18]:
In [1]:
import print_line_by_line as pll
In [2]:
reload(pll)
pll.printtonewtext('data1.txt')
In [3]:
import numpy as np
In [4]:
arr1 = np.loadtxt('data1.txt')
In [39]:
# Transpose is an attribute of the numpy array object
arr1.T
Out[39]:
In [7]:
data1 = pll.readasnumpy('data1.txt')
In [46]:
# numpy has methods that take in numpy arrays as arguments
np.sum(data1)
np.diff(data1)
Out[46]:
In [5]:
import pylab as plb
%pylab inline
In [9]:
plb.plot(data1[0], data1[1],c='r',ls=':')
Out[9]:
In [14]:
# Can save the figure under many different extensions: pdf, eps, png
plb.savefig('fig1.pdf')
In [18]:
import plot_my_data as pmd
In [19]:
# Links to this notebook and the modules it imports
# are in the etherpad
pmd.plot_in_line(data1,figname='myfigipynotebook')
In [20]:
ls
In [21]:
__name__
Out[21]:
In [22]:
reload(pmd)
Out[22]:
In [23]:
reload(pmd)
Out[23]:
In [24]:
reload(pmd)
Out[24]:
In [ ]: