Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Phyton loop issue with twitter client?

Status
Not open for further replies.

MikeDemon

Programmer
Jul 11, 2011
2
GB
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()
 
no,as python would not run. my code works but just picks up the details of the last in the text filr from twitter
 
wee need to see the code in its true indented form to be avble to advise acurately
use code tags as advised previously

I do not Have A.D.D. im just easily, Hey look a Squirrel!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top