[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Importing a weighted network from a csv file
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Importing a weighted network from a csv file |
Date: |
Fri, 6 Feb 2015 22:56:31 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
> I have a weighted network stored in a .csv file. I need to import using a
> csv.DictReader but also apply the weights in the column to the edges as we
> import
Isn't it what DictReader does by default? All the key-value pairs that do not
correspond to the source and the target vertex in the dictionary iterator that
you pass to "edges" are imported as edge attributes. Maybe the only catch is
that you have to cast them to floats after you have created the graph because
the CSV reader reads them as strings -- so maybe you'll have to do this:
g.es["weight"] = [float(x) for x in g.es["weight"]]
--
T.