Creating an edge list for Gephi with Python
For various projects including my personal ones I frequently use Gephi to make some interesting network graphs. Last summer in 2014, I did a brief analysis(it's done in Korean) on the story flow of a Korean History Drama (kinda like The Game of Thrones, but based on history) by drawing graphs with NetworkX(a python library for network analysis) and Gephi. In doing that I was in need of making edge lists of characters in csv so that Gephi could chew it nicely.
And I've just tweeked a bit of the code so that it changes this
Banana, Apple, Pear
to this, which is a bunch of all possible unique pairs.
The code and use are available on my github!
For data in Korean, you have to make sure that your csv is in UTF-8 not in ANSI.
[EDITED] After uploading the code, I found a minor error that Gephi could not read the type of edges this code had generated. I found a plugin called "Convert Excel and csv files to networks (including dynamic!)" on Gephi that allows you to directly import csv and excel files to Gephi. And to make my code work with the plugin, I deleted the header bit(Source,Target,Type). Please find the detailed instruction on my github. Thank you.