pythonnotes's posterous http://pythonnotes.posterous.com Most recent posts at pythonnotes's posterous posterous.com Thu, 19 Jul 2012 02:46:03 -0700 Grabbing from a particular index onwards http://pythonnotes.posterous.com/grabbing-from-a-particular-index-onwards http://pythonnotes.posterous.com/grabbing-from-a-particular-index-onwards From the Scraperwiki mailing list:
    You can open .xls-es then navigate around them w/ xlrd

 
I did one here: 
https://scraperwiki.com/scrapers/testing_with_the_intro_tutorial_atlanta_schedule/
 
I had like, one zillion spreadsheets all formatted exactly the same and I 
needed, like, rows[40:] out of all of them. So this scraper opened each 
one, scraped out all the rows from 40 till the end, closed the xls, went 
back to the main page and iterated down to the next xls to open. 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1080526/paulb_bigger.jpg http://posterous.com/users/ZyH4FHK2wVz Paul Bradshaw paulbradshaw Paul Bradshaw
Mon, 29 Nov 2010 09:56:58 -0800 Python lists http://pythonnotes.posterous.com/python-lists http://pythonnotes.posterous.com/python-lists #Lists are useful as a way of assigning a series of values to a particular list name
#Those values can then be called by their position (index) in the series

myfridge = ['cheese', 'milk', 'beer']

#the square brackets indicate that this is a list
#each item in the list is separated by a comma
#items can then be called as follows:

myfridge[0]

#this would call the first item in the list (index position 0)

#you can also change the contents of a list with various functions as follows

myfridge.append('ham')

#this appends - .append - the string 'ham' to the list myfridge. 
#Note the full stop before .append and the parenthesis containing the argument to be passed
#the parenthesis could also use a variable instead of a string, or a function that returns a value, or another list

myfridge.pop(-1)

#this returns the last item in the list (at index position -1) and removes it from the list at the same time (pops)

#other functions include 
#counting how many times something occurs in a list - .count('ham')
#returning the index of a particular item in a list - .index('ham')
#removing the first instance in a list of a particular item - .remove('ham')
#inserting an item in a list at a particular position - .insert(3, 'ham')
#sorting items - .sort()
#reversing the order of items - .reverse()

#other list functions can be found at http://docs.python.org/tutorial/datastructures.html

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1080526/paulb_bigger.jpg http://posterous.com/users/ZyH4FHK2wVz Paul Bradshaw paulbradshaw Paul Bradshaw