twint icon indicating copy to clipboard operation
twint copied to clipboard

CSV error

Open Regina21 opened this issue 7 years ago • 2 comments

Hello, I want to extract all tweets from the tennis player Djokovic in 2018. So I basically took the provided code "automate.py" and I just changed the username and added the time period (see code below).

However, when I run it, it extracts the tweets, but I am not able to get the desired output. I get the following error message "CRITICAL:root:twint.output:_output:CSV:Error:list indices must be integers or slices, not str list indices must be integers or slices, not str [x] output._output". I cannot find the error...

import twint
import schedule
import time
def jobone():
	print ("Fetching Tweets")
	c = twint.Config()
	# choose username (optional)
	c.Username = "djokernole"
	# choose beginning time (narrow results)
	c.Since = "2018-01-01"
	# choose beginning time (narrow results)
	c.Until = "2018-12-01"
	# set limit on total tweets
	c.Limit = 1000
	# no idea, but makes the csv format properly
	c.Store_csv = True
	# format of the csv
	c.Custom = ["date", "time", "username", "tweet", "link", "likes", "retweets", "replies", "mentions", "hashtags"]
	# change the name of the csv file
	c.Output = "filename.csv"
	twint.run.Search(c)

def jobtwo():
	print ("Fetching Tweets")
	c = twint.Config()
	# choose username (optional)
	c.Username = "djokernole"
	c.Since = "2018-01-01"
	# set limit on total tweets
	c.Until = "2018-12-01"
	# set limit on total tweets
	c.Limit = 1000
	# no idea, but makes the csv format properly
	c.Store_csv = True
	# format of the csv
	c.Custom = ["date", "time", "username", "tweet", "link", "likes", "retweets", "replies", "mentions", "hashtags"]
	# change the name of the csv file
	c.Output = "filename2.csv"
	twint.run.Search(c)

Regina21 avatar Apr 13 '19 06:04 Regina21

Hi, I'm sorry but automate.py is quite outdated

You should edit c.Custom lines according the Wiki.

I'll update the code ASAP

pielco11 avatar Apr 13 '19 17:04 pielco11

Hi, I'm sorry but automate.py is quite outdated

You should edit c.Custom lines according the Wiki.

I'll update the code ASAP

I have same problem

maheraudee avatar May 30 '19 09:05 maheraudee