-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathutils.h
More file actions
27 lines (21 loc) · 680 Bytes
/
utils.h
File metadata and controls
27 lines (21 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once
#include <sstream>
#include <fstream>
#include <vector>
#include <tuple>
// Read in the csv file and return file locations and labels as vector of tuples.
auto ReadCsv(std::string& location) -> std::vector<std::tuple<std::string /*file location*/, int64_t /*label*/>> {
std::fstream in(location, std::ios::in);
std::string line;
std::string name;
std::string label;
std::vector<std::tuple<std::string, int64_t>> csv;
while (getline(in, line))
{
std::stringstream s(line);
getline(s, name, ',');
getline(s, label, ',');
csv.push_back(std::make_tuple("../" + name, stoi(label)));
}
return csv;
}