-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimportdata.hpp
54 lines (42 loc) · 967 Bytes
/
importdata.hpp
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
#ifndef IMPORTDATA_HPP
#define IMPORTDATA_HPP
#include "h5obj.hpp"
#include <fstream>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include<algorithm>
using namespace std;
vector<string> readnames(const char* inputfilename){
vector<string> rownames;
ifstream file(inputfilename);
string temp;
while(file){
getline(file,temp);
rownames.push_back(temp);
}
file.close();
return(rownames);
}
size_t rowcount(const char* filename)
{
ifstream file(filename);
size_t rownum = std::count(std::istreambuf_iterator<char>(file),
std::istreambuf_iterator<char>(),'\n');
file.close();
return(rownum);
}
size_t colcount(const char* filename)
{
stringstream line1;
string line1s;
ifstream file(filename);
getline(file,line1s);
line1<<line1s;
size_t colnum=count(istreambuf_iterator<char>(line1),
istreambuf_iterator<char>(),'\t');
file.close();
return(colnum);
}
#endif