Commit 32eb6741 authored by Michael Ott's avatar Michael Ott
Browse files

Fix csv import for multi-column datasets

parent a77e773d
......@@ -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;
sensor.name = *i;
std::stringstream ss;
ss << 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;
std::stringstream ss;
ss << 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++;
}
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) {
......
Supports Markdown
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