graph_tool.load_graph_from_csv#
- graph_tool.load_graph_from_csv(file_name, directed=False, eprop_types=None, eprop_names=None, hashed=True, hash_type='string', skip_first=False, strip_whitespace=True, ecols=(0, 1), csv_options={'delimiter': ',', 'quotechar': '"'})[source]#
Load a graph from a
csvfile containing a list of edges and edge properties.- Parameters:
- file_name
stror file-like object File in :mod:
csvformat, with edges given in each row.- directed
bool(optional, default:False) Whether or not the graph is directed.
- eprop_typeslist of
str(optional, default:None) List of edge property types to be read from remaining columns (if this is
None, all properties will be of typestring.- eprop_nameslist of
str(optional, default:None) List of edge property names to be used for the remaining columns (if this is
None, andskip_firstisTruetheir values will be obtained from the first line, otherwise they will be calledc1, c2, ...).- hashed
bool(optional, default:True) If
Truethe vertex values in the edge list are not assumed to correspond to vertex indices directly. In this case they will be mapped to vertex indices according to the order in which they are encountered, and a vertex property map with the vertex values is returned.- hash_type
str(optional, default:string) If
hashed == True, this will determined the type of the vertex values. It can be any property map value type (seePropertyMap).- skip_first
bool(optional, default:False) If
Truethe first line of the file will be skipped.- strip_whitespace
bool(optional, default:True) If
Truewhitespace will be striped from the start and end of values, before processing them.- ecolspair of
int(optional, default:(0,1)) Line columns used as source and target for the edges.
- csv_options
dict(optional, default:{"delimiter": ",", "quotechar": '"'}) Options to be passed to the
csv.reader()parser.
- file_name
- Returns:
- g
Graph The loaded graph. It will contain additional columns in the file as internal edge property maps. If
hashed == True, it will also contain an internal vertex property map with the vertex names.
- g