Commit 878fb933 authored by Tiago Peixoto's avatar Tiago Peixoto

load_graph_from_csv(): Fix loading from compressed files with Python 3

This fixes issue #593
parent 354c0a1a
Pipeline #494 failed with stage
in 441 minutes and 42 seconds
......@@ -3334,13 +3334,13 @@ def load_graph_from_csv(file_name, directed=False, eprop_types=None,
if isinstance(file_name, (str, unicode)):
if file_name.endswith(".xz"):
try:
file_name = lzma.open(file_name, mode="r")
file_name = lzma.open(file_name, mode="rt")
except ImportError:
raise NotImplementedError("lzma compression is only available in Python >= 3.3")
elif file_name.endswith(".gz"):
file_name = gzip.open(file_name, mode="r")
file_name = gzip.open(file_name, mode="rt")
elif file_name.endswith(".bz2"):
file_name = bz2.open(file_name, mode="r")
file_name = bz2.open(file_name, mode="rt")
else:
file_name = open(file_name, "r")
_csv_options = {"delimiter": ",", "quotechar": '"'}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment