Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I really enjoy your site. You have a lot of helpful and friendly experts who contribute so willingly. Thank you for past (and future) technical advice..."

Geography

Where in the world do Tek-Tips members come from?

Phyton loop issue with twitter client?

MikeDemon (Programmer)
11 Jul 11 12:23
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()
feherke (Programmer)
11 Jul 11 12:28
Hi

Is your real code unindented ?

Next time please post your code between [code] and [/code] TGML tags.
 

Feherke.
http://free.rootshell.be/~feherke/

MikeDemon (Programmer)
11 Jul 11 13:26
no,as python would not run. my code works but just picks up the details of the last in the text filr from twitter
IPGuru (TechnicalUser)
12 Jul 11 5:44
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!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close