Transcript for Monday 19 November (glob)
| categories: Transcripts
Transcript for today.
# IPython log file
cd ~/Dropbox/116
ls
from glob import glob
glob('*.txt')
#[Out]# ['gb.txt', 'babies.txt', '1-1000.txt']
ls MyData
glob('MyData/*.txt')
#[Out]# ['MyData/hoho.txt', 'MyData/bar.txt', 'MyData/gary.txt', 'MyData/foo.txt']
line = 'bird 7.35'
line.split()
#[Out]# ['bird', '7.35']
line = 'bird|7.35'
line.split()
#[Out]# ['bird|7.35']
line.split('|')
#[Out]# ['bird', '7.35']
'foo' == 'bar'
#[Out]# False
from csv import DictReader
reader = DictReader(file('example.csv'))
for row in reader:
print row
reader = DictReader(file('example.csv'))
row1 = reader.next()
row1
#[Out]# {'Day No': '1',
#[Out]# 'Description': 'lousy day',
#[Out]# 'Rain Amount': '0.0',
#[Out]# 'Temperature': '47.5'}
row1['Day No']
#[Out]# '1'
reader = DictReader(file('example.csv'))
for row in reader:
print row['Day No'], row['Description']