Re: linecache and glob

2008-01-07 Thread jo3c
On Jan 4, 5:25 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > jo3c wrote: > > i have a 2000 files with header and data > > i need to get the date information from the header > > then insert it into my database > > i am doing it in batch so i use glob.glob('/mydata/*/*/*.txt') > > to get the date on

Re: linecache and glob

2008-01-04 Thread Fredrik Lundh
jo3c wrote: > i have a 2000 files with header and data > i need to get the date information from the header > then insert it into my database > i am doing it in batch so i use glob.glob('/mydata/*/*/*.txt') > to get the date on line 4 in the txt file i use > linecache.getline('/mydata/myfile.txt/,

Re: linecache and glob

2008-01-03 Thread Shane Geiger
import linecache import glob # reading from one file print linecache.getline('notes/python.txt',4) 'http://www.python.org/doc/current/lib/\n' # reading from many files for filename in glob.glob('/etc/*'): print linecache.getline(filename,4) jo3c wrote: > hi everyone happy new year! > im a

Re: linecache and glob

2008-01-03 Thread jo3c
i have a 2000 files with header and data i need to get the date information from the header then insert it into my database i am doing it in batch so i use glob.glob('/mydata/*/*/*.txt') to get the date on line 4 in the txt file i use linecache.getline('/mydata/myfile.txt/, 4) but if i use linecac

Re: linecache and glob

2008-01-03 Thread Jeremy Dillworth
Hello, Welcome to Python! glob returns a list of filenames, but getline is made to work on just one filename. So you'll need to iterate over the list returned by glob. >>> import linecache, glob >>> for filename in glob.glob('/etc/*'): >>> print linecache.getline(filename, 4) Maybe you coul