pep8speaks: Hello @crsqq! Thanks for opening this PR. 



* In the file [`networkx/readwrite/tests/test_edgelist.py`](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py):

> [Line 117:17](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L117): [E126](https://duckduckgo.com/?q=pep8%20E126) continuation line over-indented for hanging indent
> [Line 117:68](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L117): [E231](https://duckduckgo.com/?q=pep8%20E231) missing whitespace after ':'
> [Line 118:21](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L118): [E128](https://duckduckgo.com/?q=pep8%20E128) continuation line under-indented for visual indent
> [Line 118:51](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L118): [E231](https://duckduckgo.com/?q=pep8%20E231) missing whitespace after ':'
> [Line 121:5](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L121): [F811](https://duckduckgo.com/?q=pep8%20F811) redefinition of unused 'test_read_edgelist_5' from line 103
> [Line 135:17](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L135): [E126](https://duckduckgo.com/?q=pep8%20E126) continuation line over-indented for hanging indent
> [Line 135:68](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L135): [E231](https://duckduckgo.com/?q=pep8%20E231) missing whitespace after ':'
> [Line 136:21](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L136): [E128](https://duckduckgo.com/?q=pep8%20E128) continuation line under-indented for visual indent
> [Line 136:51](https://github.com/networkx/networkx/blob/cca13b9f799689e9aa1fa9323b5ef0bc94445396/networkx/readwrite/tests/test_edgelist.py#L136): [E231](https://duckduckgo.com/?q=pep8%20E231) missing whitespace after ':'

Please install and run [psf/black](https://github.com/psf/black).
diff --git a/networkx/readwrite/edgelist.py b/networkx/readwrite/edgelist.py
index 72afe1a7c..5183071d1 100644
--- a/networkx/readwrite/edgelist.py
+++ b/networkx/readwrite/edgelist.py
@@ -270,7 +270,11 @@ def parse_edgelist(
         elif data is True:
             # no edge types specified
             try:  # try to evaluate as dictionary
-                edgedata = dict(literal_eval(" ".join(d)))
+                if delimiter == ",":
+                    edgedata_str = ",".join(d)
+                else:
+                    edgedata_str = " ".join(d)
+                edgedata = dict(literal_eval(edgedata_str.strip()))
             except BaseException as e:
                 raise TypeError(
                     f"Failed to convert edge data ({d}) " f"to dictionary."

Parse edgelist bug
When calling `parse_edgelist()` using comma delimiters, it will fail to parse correctly fro edges with multiple attributes.

Ex. of bad edge:
`1,2,{'test':1, 'test_other':2}`

`parse_edgelist()` will recognize the comma in the braces as delimiter and try to split them up.
diff --git a/networkx/readwrite/tests/test_edgelist.py b/networkx/readwrite/tests/test_edgelist.py
index 2e1a2424f..31f214566 100644
--- a/networkx/readwrite/tests/test_edgelist.py
+++ b/networkx/readwrite/tests/test_edgelist.py
@@ -100,6 +100,48 @@ class TestEdgelist:
             G.edges(data=True), [(1, 2, {"weight": 2.0}), (2, 3, {"weight": 3.0})]
         )
 
+    def test_read_edgelist_5(self):
+        s = b"""\
+# comment line
+1 2 {'weight':2.0, 'color':'green'}
+# comment line
+2 3 {'weight':3.0, 'color':'red'}
+"""
+        bytesIO = io.BytesIO(s)
+        G = nx.read_edgelist(bytesIO, nodetype=int, data=False)
+        assert_edges_equal(G.edges(), [(1, 2), (2, 3)])
+
+        bytesIO = io.BytesIO(s)
+        G = nx.read_edgelist(bytesIO, nodetype=int, data=True)
+        assert_edges_equal(
+            G.edges(data=True),
+            [
+                (1, 2, {"weight": 2.0, "color": "green"}),
+                (2, 3, {"weight": 3.0, "color": "red"}),
+            ],
+        )
+
+    def test_read_edgelist_6(self):
+        s = b"""\
+# comment line
+1, 2, {'weight':2.0, 'color':'green'}
+# comment line
+2, 3, {'weight':3.0, 'color':'red'}
+"""
+        bytesIO = io.BytesIO(s)
+        G = nx.read_edgelist(bytesIO, nodetype=int, data=False, delimiter=",")
+        assert_edges_equal(G.edges(), [(1, 2), (2, 3)])
+
+        bytesIO = io.BytesIO(s)
+        G = nx.read_edgelist(bytesIO, nodetype=int, data=True, delimiter=",")
+        assert_edges_equal(
+            G.edges(data=True),
+            [
+                (1, 2, {"weight": 2.0, "color": "green"}),
+                (2, 3, {"weight": 3.0, "color": "red"}),
+            ],
+        )
+
     def test_write_edgelist_1(self):
         fh = io.BytesIO()
         G = nx.OrderedGraph()

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest cython distro pytest-cov pytest-xdist pytest-mock pytest-asyncio pytest-bdd pytest-benchmark pytest-randomly responses mock hypothesis freezegun trustme requests-mock requests tomlkit
apt-get update apt-get install -y gcc
3.9
requirements/default.txt requirements/test.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==25.3.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
codecov==2.1.13
coverage==7.8.0
cryptography==44.0.2
Cython==3.0.12
decorator==5.2.1
distro==1.9.0
exceptiongroup==1.2.2
execnet==2.1.1
freezegun==1.5.1
gherkin-official==29.0.0
hypothesis==6.130.5
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
Mako==1.3.9
MarkupSafe==3.0.2
mock==5.2.0
-e git+https://github.com/networkx/networkx.git@ab7429c62806f1242c36fb81c1b1d801b4cca7a3#egg=networkx
packaging==24.2
parse==1.20.2
parse_type==0.6.4
pluggy==1.5.0
py-cpuinfo==9.0.0
pycparser==2.22
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-bdd==8.1.0
pytest-benchmark==5.1.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-randomly==3.16.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
requests-mock==1.12.1
responses==0.25.7
six==1.17.0
sortedcontainers==2.4.0
tomli==2.2.1
tomlkit==0.13.2
trustme==1.2.1
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0

name: networkx
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==25.3.0
      - certifi==2025.1.31
      - cffi==1.17.1
      - charset-normalizer==3.4.1
      - codecov==2.1.13
      - coverage==7.8.0
      - cryptography==44.0.2
      - cython==3.0.12
      - decorator==5.2.1
      - distro==1.9.0
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - freezegun==1.5.1
      - gherkin-official==29.0.0
      - hypothesis==6.130.5
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - mako==1.3.9
      - markupsafe==3.0.2
      - mock==5.2.0
      - packaging==24.2
      - parse==1.20.2
      - parse-type==0.6.4
      - pluggy==1.5.0
      - py-cpuinfo==9.0.0
      - pycparser==2.22
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-bdd==8.1.0
      - pytest-benchmark==5.1.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pytest-randomly==3.16.0
      - pytest-xdist==3.6.1
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - requests==2.32.3
      - requests-mock==1.12.1
      - responses==0.25.7
      - six==1.17.0
      - sortedcontainers==2.4.0
      - tomli==2.2.1
      - tomlkit==0.13.2
      - trustme==1.2.1
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - zipp==3.21.0
prefix: /opt/conda/envs/networkx

networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_read_edgelist_6
networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_read_edgelist_4 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_edgelist_integers networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_edgelist_multigraph networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_latin1_issue networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_read_edgelist_2 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_write_edgelist_2 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_edgelist_multidigraph networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_write_edgelist_3 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_latin1 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_edgelist_graph networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_edgelist_digraph networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_read_edgelist_1 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_write_edgelist_1 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_read_edgelist_3 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_unicode networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_read_edgelist_5 networkx/readwrite/tests/test_edgelist.py::TestEdgelist::test_write_edgelist_4
networkx/readwrite/edgelist.py
networkx/readwrite/edgelist.py