[Numpy-discussion] skip lines at the end of file with loadtxt

Massimo Di Stefano massimodisasha@gmail....
Tue Oct 25 14:28:13 CDT 2011


i'm tring to generate an array reading a txt file from internet.
my target is to use python instead of matlab, to replace this steps in matlab :

url=['http://www.cdc.noaa.gov/Correlation/amon.us.long.data']; urlwrite(url,'file.txt');

i'm using this code :

urllib.urlretrieve('http://www.cdc.noaa.gov/Correlation/amon.us.long.data', 'file.txt') a = np.loadtxt('file.txt', skiprows=1)

but it fails becouse of the txt description at the end of the file,

do you know if exist a way to skip the X lines at the end, 

something like "skipmultiplerows='1,-4'" (to skip the first and the last 4 rows in the file)

or i have to use some sort of string manipulation (readlines?) instead ?


Thanks!

--Massimo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20111025/1b561625/attachment.html 


More information about the NumPy-Discussion mailing list