linecache and glob

Shane Geiger sgeiger at ncee.net
Fri Jan 4 02:04:56 EST 2008


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 newbie to python
> i have a question
> by using linecache and glob
> how do i read a specific line from a file in a batch and then insert
> it into database?
>
> because it doesn't work! i can't use glob wildcard with linecache
>
>   
>>>> import linecache
>>>> linecache.getline(glob.glob('/etc/*', 4)
>>>>         
>
> doens't work
>
> is there any better methods??? thank you very much in advance
>
> jo3c
>   


-- 
Shane Geiger
IT Director
National Council on Economic Education
sgeiger at ncee.net  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy




More information about the Python-list mailing list