fixed issue within file-reader when reading empty data-parts
This commit is contained in:
@@ -156,16 +156,25 @@ namespace Offline {
|
|||||||
|
|
||||||
while(!inp.eof() && !inp.bad()) {
|
while(!inp.eof() && !inp.bad()) {
|
||||||
|
|
||||||
|
// read the next line from the file
|
||||||
|
// this ensures that we will not read beyond one line within the next steps
|
||||||
|
std::string line;
|
||||||
|
std::getline(inp, line);
|
||||||
|
|
||||||
|
// create a stream for the read line
|
||||||
|
std::stringstream sline(line);
|
||||||
|
|
||||||
uint64_t ts;
|
uint64_t ts;
|
||||||
char delim;
|
char delim;
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
std::string data;
|
std::string data;
|
||||||
|
|
||||||
inp >> ts;
|
// split the line
|
||||||
inp >> delim;
|
sline >> ts;
|
||||||
inp >> idx;
|
sline >> delim;
|
||||||
inp >> delim;
|
sline >> idx;
|
||||||
inp >> data;
|
sline >> delim;
|
||||||
|
sline >> data; // might be "" if there is no data
|
||||||
|
|
||||||
if (idx == (int)Sensor::WIFI) {parseWiFi(ts, data);}
|
if (idx == (int)Sensor::WIFI) {parseWiFi(ts, data);}
|
||||||
else if (idx == (int)Sensor::BEACON) {parseBeacons(ts, data);}
|
else if (idx == (int)Sensor::BEACON) {parseBeacons(ts, data);}
|
||||||
@@ -267,6 +276,8 @@ namespace Offline {
|
|||||||
WiFiMeasurements wifi;
|
WiFiMeasurements wifi;
|
||||||
Splitter s(data, sep);
|
Splitter s(data, sep);
|
||||||
|
|
||||||
|
//if (s.empty()) {return;}
|
||||||
|
|
||||||
// the -1 is due to some old files containing a trailing ";" resulting in one additional stray column
|
// the -1 is due to some old files containing a trailing ";" resulting in one additional stray column
|
||||||
for (size_t i = 0; i < s.size()-1; i += 3) {
|
for (size_t i = 0; i < s.size()-1; i += 3) {
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public:
|
|||||||
|
|
||||||
size_t size() const {return split.size();}
|
size_t size() const {return split.size();}
|
||||||
|
|
||||||
|
bool empty() const {return split.empty();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void build() {
|
void build() {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
|
|
||||||
static inline std::string getDataFile(const std::string& name) {
|
static inline std::string getDataFile(const std::string& name) {
|
||||||
//return "/mnt/data/workspaces/Indoor/tests/data/" + name;
|
//return "/mnt/data/workspaces/Indoor/tests/data/" + name;
|
||||||
return "/home/toni/Documents/programme/localization/Indoor/tests/data/" + name;
|
return "/mnt/vm/paper/diss/code/Indoor/tests/data/" + name;
|
||||||
|
//return "/home/toni/Documents/programme/localization/Indoor/tests/data/" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
tests/data/fileReader1.txt
Normal file
5
tests/data/fileReader1.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
136731;0;1.6424103;2.4756012;14.106628
|
||||||
|
136728;8;
|
||||||
|
136731;1;0.5573883;2.0301208;9.57785
|
||||||
|
136733;3;-0.8585968;-1.057785;-1.1313019
|
||||||
|
136831;8;68c63a9f81f1;2422;-55;5ccf7fc40df3;2422;-66
|
||||||
18
tests/sensors/offline/TestReader.cpp
Normal file
18
tests/sensors/offline/TestReader.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifdef WITH_TESTS
|
||||||
|
|
||||||
|
#include "../../Tests.h"
|
||||||
|
|
||||||
|
#include "../../../sensors/offline/FileReader.h"
|
||||||
|
|
||||||
|
TEST(FileReader, test1) {
|
||||||
|
|
||||||
|
std::string file = "/tmp/FirstTest.csv";//getDataFile("fileReader1.txt");
|
||||||
|
Offline::FileReader reader(file);
|
||||||
|
|
||||||
|
int i = 0; (void) i;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user