Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Jansson
LabComm
Commits
17670b9d
Commit
17670b9d
authored
10 years ago
by
Tommy Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Allow mixed registrations and data in CSV tool.
parent
9c7a9e2e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/lc2csv.py
+26
-22
26 additions, 22 deletions
tools/lc2csv.py
with
26 additions
and
22 deletions
tools/lc2csv.py
+
26
−
22
View file @
17670b9d
...
@@ -5,11 +5,11 @@ import labcomm
...
@@ -5,11 +5,11 @@ import labcomm
class
Reader
(
object
):
class
Reader
(
object
):
def
__init__
(
self
,
file
):
def
__init__
(
self
,
_
file
):
self
.
file
=
open
(
file
)
self
.
_
file
=
open
(
_
file
)
def
read
(
self
,
count
):
def
read
(
self
,
count
):
data
=
self
.
file
.
read
(
count
)
data
=
self
.
_
file
.
read
(
count
)
if
len
(
data
)
==
0
:
if
len
(
data
)
==
0
:
raise
EOFError
()
raise
EOFError
()
return
data
return
data
...
@@ -70,37 +70,41 @@ def dump_labels(current, _type):
...
@@ -70,37 +70,41 @@ def dump_labels(current, _type):
def
main
():
def
main
():
if
len
(
sys
.
argv
)
!=
2
:
sys
.
exit
(
"
Give input file as argument
\n
"
)
d
=
labcomm
.
Decoder
(
Reader
(
sys
.
argv
[
1
]))
d
=
labcomm
.
Decoder
(
Reader
(
sys
.
argv
[
1
]))
seen
=
{}
seen
=
{}
current
=
{}
current
=
{}
_type
=
{}
_type
=
{}
# Do one pass through the file to find all registrations.
while
True
:
while
True
:
try
:
try
:
(
o
,
t
)
=
d
.
decode
()
o
,
t
=
d
.
decode
()
except
EOFError
:
if
o
is
None
:
break
if
o
==
None
:
# Type declaration
seen
[
t
.
name
]
=
0
seen
[
t
.
name
]
=
0
_type
[
t
.
name
]
=
t
_type
[
t
.
name
]
=
t
else
:
else
:
current
[
t
.
name
]
=
o
current
[
t
.
name
]
=
o
if
len
(
current
)
==
len
(
_type
):
except
EOFError
:
# We have got one sample of each
break
break
dump_labels
(
current
,
_type
)
dump_labels
(
current
,
_type
)
n
=
0
while
o
!=
None
:
# Do another pass to extract the data.
if
seen
[
t
.
name
]
>
n
:
current
=
{}
n
=
seen
[
t
.
name
]
d
=
labcomm
.
Decoder
(
Reader
(
sys
.
argv
[
1
]))
dump
(
current
,
_type
)
while
True
:
current
[
t
.
name
]
=
o
seen
[
t
.
name
]
+=
1
try
:
try
:
(
o
,
t
)
=
d
.
decode
()
o
,
t
=
d
.
decode
()
if
o
is
not
None
:
current
[
t
.
name
]
=
o
if
len
(
current
)
==
len
(
_type
):
# Assume that samples arrive at different rates.
# Trigger on everything once we have a value for
# each column.
dump
(
current
,
_type
)
except
EOFError
:
except
EOFError
:
break
break
dump
(
current
,
_type
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment