Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CPUnetLOG
CPUnetPLOT
Commits
d1ca0ad6
Commit
d1ca0ad6
authored
Aug 02, 2019
by
Mario Hock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support bz2 files transparently
parent
1f11494e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
cnl_library.py
cnl_library.py
+10
-2
No files found.
cnl_library.py
View file @
d1ca0ad6
...
...
@@ -155,7 +155,15 @@ class CNLParser:
if
(
os
.
path
.
isdir
(
self
.
filename
)
):
raise
self
.
WrongFileFormat_Exception
()
with
open
(
self
.
filename
)
as
in_file
:
## automatically handle compressed files
if
self
.
filename
.
endswith
(
".bz2"
):
import
bz2
self
.
open_func
=
bz2
.
open
else
:
self
.
open_func
=
open
with
self
.
open_func
(
self
.
filename
,
mode
=
"tr"
,
encoding
=
"UTF-8"
)
as
in_file
:
try
:
## Check file format version.
if
(
not
in_file
.
readline
()
==
"%% CPUnetLOGv1
\n
"
):
...
...
@@ -188,7 +196,7 @@ class CNLParser:
## Read from file.
with
open
(
self
.
filename
)
as
in_file
:
with
self
.
open_func
(
self
.
filename
,
mode
=
"tr"
,
encoding
=
"UTF-8"
)
as
in_file
:
## Find start of the CSV part.
csv_reader
=
csv
.
reader
(
cnl_slice
(
in_file
,
"%% Begin_Body"
,
"%% End_Body"
),
skipinitialspace
=
True
)
csv_header
=
next
(
csv_reader
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment