Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
dcdb
dcdb
Commits
32eb6741
Commit
32eb6741
authored
Mar 27, 2018
by
Michael Ott
Browse files
Fix csv import for multi-column datasets
parent
a77e773d
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/dcdbcsvimport/dcdbcsvimport.cpp
View file @
32eb6741
...
...
@@ -156,19 +156,19 @@ int main(int argc, char** argv)
int
col
=
0
;
for
(
boost
::
tokenizer
<
boost
::
escaped_list_separator
<
char
>
>::
iterator
i
=
tk
.
begin
();
i
!=
tk
.
end
();
++
i
)
{
if
(
i
==
tk
.
begin
()
)
{
continue
;
}
sensor_t
sensor
;
s
ensor
.
name
=
*
i
;
s
td
::
stringstream
ss
;
s
s
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
suffixLen
)
<<
std
::
hex
<<
topics
;
;
sensor
.
topic
=
prefix
+
ss
.
str
(
);
sensor
.
publicName
=
prefix
+
"."
+
sensor
.
name
;
std
::
replace
(
sensor
.
publicName
.
begin
(),
sensor
.
publicName
.
end
(),
' '
,
'_'
)
;
sensors
.
insert
(
std
::
pair
<
int
,
sensor_t
>
(
col
,
sensor
));
topics
++
;
if
(
col
!=
tsColumn
)
{
sensor_t
sensor
;
sensor
.
name
=
*
i
;
s
td
::
stringstream
ss
;
ss
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
suffixLen
)
<<
std
::
hex
<<
topics
;;
s
ensor
.
topic
=
prefix
+
ss
.
str
()
;
s
ensor
.
publicName
=
prefix
+
"."
+
sensor
.
name
;
std
::
replace
(
sensor
.
publicName
.
begin
(),
sensor
.
publicName
.
end
(),
' '
,
'_'
);
sensor
s
.
insert
(
std
::
pair
<
int
,
sensor_t
>
(
col
,
sensor
))
;
topics
++
;
}
col
++
;
}
/* Read actual sensor readings */
...
...
@@ -188,10 +188,10 @@ int main(int argc, char** argv)
col
=
0
;
for
(
boost
::
tokenizer
<
boost
::
escaped_list_separator
<
char
>
>::
iterator
i
=
tk
.
begin
();
i
!=
tk
.
end
();
++
i
)
{
if
((
columns
.
size
()
==
0
)
||
(
columns
.
find
(
col
)
!=
columns
.
end
()))
{
if
((
(
columns
.
size
()
==
0
)
||
(
columns
.
find
(
col
)
!=
columns
.
end
()))
&&
col
!=
tsColumn
)
{
std
::
cout
<<
ts
.
getRaw
()
<<
" "
<<
col
<<
" "
<<
sensors
[
col
].
topic
<<
" "
<<
*
i
<<
std
::
endl
;
try
{
DCDB
::
SensorId
sid
(
sensors
[
col
-
1
].
topic
);
DCDB
::
SensorId
sid
(
sensors
[
col
].
topic
);
sensorDataStore
.
insert
(
&
sid
,
ts
.
getRaw
(),
std
::
stoll
(
*
i
));
}
catch
(
std
::
exception
&
e
)
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment