Yesterday on Twitter, Patrick O’Shaughnessy asked people to name a product or service that they would be willing to pay more for than they currently do. As of this morning there are about 250 replies–some are silly, but some are genuine. Patrick then asked if anyone could extract and parse the responses.

I volunteered to help put the usernames and text of the responses into a CSV. The Python script that I wrote for this is short enough to embed here (also available as a gist):

import csv
import tweepy

# get credentials at developer.twitter.com
auth = tweepy.OAuthHandler('API Key', 'API Secret')
auth.set_access_token('Access Token', 'Access Token Secret')

api = tweepy.API(auth)

# update these for whatever tweet you want to process replies to
name = 'patrick_oshag'
tweet_id = '1101551802930077696'

replies=[]
for tweet in tweepy.Cursor(api.search,q='to:'+name, result_type='recent', timeout=999999).items(1000):
    if hasattr(tweet, 'in_reply_to_status_id_str'):
        if (tweet.in_reply_to_status_id_str==tweet_id):
            replies.append(tweet)

with open('replies_clean.csv', 'wb') as f:
    csv_writer = csv.DictWriter(f, fieldnames=('user', 'text'))
    csv_writer.writeheader()
    for tweet in replies:
        row = {'user': tweet.user.screen_name, 'text': tweet.text.encode('ascii', 'ignore').replace('\n', ' ')}
        csv_writer.writerow(row)

This is a quick-and-dirty script that you can update for whichever tweet you are interested in. For this particular conversation, the data is available in a Google Sheet here.