python 2.7 - How i fix this syntax error for a tweepy script? -


hello i'm trying learn programing project.

i've been working on simple script (using tweepy) download tweets search of keyword .csv format. keep getting sintax error in multiple lines (from 28 38) , don't know wrong @ point, can tell me what's wrong?

here code i've been working on...

    # -*- coding: utf-8 -*- #import modules import tweepy tweepy import stream tweepy import oauthhandler tweepy.streaming import streamlistener import unicodecsv unidecode import unidecode import csv  textblob import textblob  ckey = "xxxxxxxxxxxxxxxxxx" csecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" atoken = "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxx" asecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  oauth_keys = {'consumer_key':ckey, 'consumer_secret':csecret, 'access_token_key':atoken, 'access_token_secret':asecret} auth = tweepy.oauthhandler(oauth_keys['consumer_key'], oauth_keys['consumer_secret']) api = tweepy.api(auth) fname= raw_input("nombre del archivo: ")+'.csv'  tweet in tweepy.cursor(api.search, q=('dulceveneno'), since='2014-09-16', until='2017-07-25').items(5):      tweet_info = [tweet.author.name.encode('utf8')                 tweet.author.screen_name.encode('utf8')                 tweet.created_at                 tweet.text.encode('utf8')                 tweet.retweeted                 tweet.favorited                 tweet.user.location.encode('utf8')                 tweet.user.time_zone                 tweet.geo                 tweet.entities.get('hashtags')]      open(fname, 'wb') file:         writer = unicodecsv.writer(file, delimiter = ',', quotechar = '"')        # write header row.         writer.writerow(["nombre",                          "username",                          "fecha",                          "tweet",                          "retweet?"                          "favs"                          "ubicaciĆ³n",                          "horario",                          "geo",                          "hashtags"])               # write data csv.             writer.writerow(tweet_info)           # show progress.         print("done!" % q) 

the problem in "tweet_info" part guess...

you haven't posted actual error yet, can see tweet_info not have commas , elements in list.

it should be:

tweet_info = [tweet.author.name.encode('utf8'),             tweet.author.screen_name.encode('utf8'),             tweet.created_at,             tweet.text.encode('utf8'),             tweet.retweeted,             tweet.favorited,             tweet.user.location.encode('utf8'),             tweet.user.time_zone,             tweet.geo,             tweet.entities.get('hashtags')] 

Comments

Popular posts from this blog

javascript - Replicate keyboard event with html button -

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Web audio api 5.1 surround example not working in firefox -