The code below works but does not loop through each name in the txt file (loops only when i just want to print their names from the text file) , it only returns the details of the last user in the list rather than returning individual user details one by one. i use Phyton twitter wrapper
Txt file have about 50 users. And always returns details of the last user in the list.
Thank you for your time.
import csv, math, time
import twitter as twitterapi
api = twitter.Api(consumer_key='uTZrt1d5y3ZStmHqIIgsg',
consumer_secret='sqZg5AhJoBosLrnM',
access_token_key='221834337-VjCsNhcoA1',
access_token_secret='cO0oyhP'uTZrt1d5y3ZStmHqIIgsg')
listofnames = file('twit.txt').readlines()
listofnames = [name.strip() for name in listofnames]
csvfile=open('twittercounts.csv','ab')
csvout=csv.writer(csvfile,dialect='exc…
for name in listofnames:
account = api.GetUser(name)
followers = account.followers_count
csvout.writerow([name, followers])
print name + ", " + str(followers)
csvfile.close()