-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathread_file.cpp
73 lines (61 loc) · 1.52 KB
/
read_file.cpp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <iterator>
#include <boost/multi_array.hpp>
using namespace std;
std::vector<double> readRow(std::string row) {
std::vector<double> retval;
std::istringstream is(row);
double num;
while (is >> num)
retval.push_back(num);
return retval;
}
std::vector<std::vector<double> > readVector(std::istream &is) {
std::string line;
std::vector<std::vector<double> > retval;
while (std::getline(is, line))
retval.push_back(readRow(line));
return retval;
}
std::vector<std::vector<double> > readFile(char *filename)
{
ifstream in(filename);
std::vector<std::vector<double> > retval = readVector(in);
in.close();
return retval;
}
std::vector<string > readNames(char *filename)
{
std::vector<string > retval;
ifstream in(filename);
std::string line;
std::getline(in, line);
std::istringstream is(line);
string st;
while (is >> st)
retval.push_back(st);
in.close();
return retval;
}
int main (int argc,char *argv[]) {
// std::vector<std::vector<double> > r = readFile("sensitivity.txt");
// for (int i=0;i<r.size();i++)
// {
// cout << r[i].size();
// /*for (int j=0;j<r[i].size();j++)
// {
// //cout << r[i][j] << " ";
//
// */
// cout << endl;
// }
std::vector<string > r = readNames("cell_names.txt");
for (int i=0; i<r.size(); i++)
cout << r[i] << endl;
return 0;
}