T2G: Convert (all) Twitter mentions to Gephi format

EDIT 07/10/13: A new version of T2G for Python has been posted here–it has options to extract only retweets or only mentions, among other new features.

A few weeks ago I posted a spreadsheet that converted tweet mention data into Gephi format for social network analysis. A key limitation of that spreadsheet is that it only converts the first name mentioned in each tweet, discarding the rest. For example, for the following tweet:

that spreadsheet would pull @alexhanna into the Gephi file as one of my mentions but not @cfwells or @kbculver.

To remedy this issue, I’ve created T2G, a solution that converts all Twitter mention data fed into it to Gephi format. T2G comes in two flavors, Python and PHP, each of which does the same thing. The PHP edition is more user-friendly, while the Python edition is faster and easier to set up. All you need to do is supply a CSV file containing two columns: the first (leftmost) filled with the tweet authors’ usernames, and the second filled with their corresponding tweets. You’ll find additional instructions in an extended comment at the top of each script. Please ensure that you have the appropriate interpreter installed (PHP or Python) before trying to use either of these scripts.

Both of these scripts produce equivalent output, albeit in a slightly different order (you can rank the data in alphabetical order to check if you like).

You can test a “lite” version of the PHP edition below–it will convert only the first 100 tweets in your file. Feel free to test it using this sample file, which contains some of my own recent tweets formatted to the above specifications.

T2G Lite, PHP Edition 0.1

3 comments

  1. Hi Deen,

    Seems I’m hitting a size limit

    Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 141 bytes) in /home/jgroshek/jgroshek.com/T2G/t2g.php on line 22

    Any ideas?

    Thanks,

    Jacob

Leave a Reply

Your email address will not be published. Required fields are marked *