summaryrefslogtreecommitdiff
path: root/networkx/readwrite/edgelist.py
diff options
context:
space:
mode:
Diffstat (limited to 'networkx/readwrite/edgelist.py')
-rw-r--r--networkx/readwrite/edgelist.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/networkx/readwrite/edgelist.py b/networkx/readwrite/edgelist.py
index 239efdbe..57de2c5f 100644
--- a/networkx/readwrite/edgelist.py
+++ b/networkx/readwrite/edgelist.py
@@ -183,7 +183,8 @@ def parse_edgelist(
lines : list or iterator of strings
Input data in edgelist format
comments : string, optional
- Marker for comment lines. Default is `'#'`
+ Marker for comment lines. Default is `'#'`. To specify that no character
+ should be treated as a comment, use ``comments=None``.
delimiter : string, optional
Separator for node labels. Default is `None`, meaning any whitespace.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
@@ -238,11 +239,12 @@ def parse_edgelist(
G = nx.empty_graph(0, create_using)
for line in lines:
- p = line.find(comments)
- if p >= 0:
- line = line[:p]
- if not line:
- continue
+ if comments is not None:
+ p = line.find(comments)
+ if p >= 0:
+ line = line[:p]
+ if not line:
+ continue
# split line, should have 2 or more
s = line.strip().split(delimiter)
if len(s) < 2:
@@ -314,7 +316,8 @@ def read_edgelist(
opened in 'rb' mode.
Filenames ending in .gz or .bz2 will be uncompressed.
comments : string, optional
- The character used to indicate the start of a comment.
+ The character used to indicate the start of a comment. To specify that
+ no character should be treated as a comment, use ``comments=None``.
delimiter : string, optional
The string used to separate values. The default is whitespace.
create_using : NetworkX graph constructor, optional (default=nx.Graph)