Transforming GDF to JSON
Gephi is an excellent tool to get easy and fast results. However, if we want to present the graph interactively on a website, we will need to implement a different kind of visualization. In order to work with the graph in the web, we need to transform our .gdf
file to the JSON format.
First we need to import the libraries numpy
and json
. See Chapter 2, Preprocessing the Data, for more information about the JSON format:
import numpy as np import json
The numpy function genfromtxt
will obtain only the ID and Name from the nodes.csv
file, using the usecols
attribute in the 'object'
format:
nodes = np.genfromtxt("nodes.csv", dtype='object', delimiter=',', skip_header=1, usecols=(0,1))
Then, the numpy function genfromtxt
will ...
Get Practical Data Analysis - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.