ATTPCROOT
0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
|
A simple CSV reader w/ modern cpp features. More...
#include <AtCSVReader.h>
Public Member Functions | |
T | operator[] (std::size_t index) const |
std::size_t | size () const |
const std::string & | getLine () const |
void | readNextLine (std::istream &stream) |
A simple CSV reader w/ modern cpp features.
Assumes no commas or newlines in the file except as deliminators (ie you can't escape them) Will work for strings or basic numbers (basically anything that stringstream is overloaded for Skips over entries that don't match the type. i.e. CSVRow<int> will parse "0,tr,-2" into {0,-2} Supports ranged loops, example below
std::ifstream file("input.csv");
for(auto& row : CSVRange<double>(file)) std::cout << "4th Element(" << row[3] << ")" << std::endl; for(auto& row : CSVRange<double>(file)) for(int i = 0; i < row.size(); ++i) std::cout << i + 1 << "th Element(" << row[i] << ")" << std::endl;
Based on: https://stackoverflow.com/questions/1120140/how-can-i-read-and-parse-csv-files-in-c Represents a row of CSV file of type T
Definition at line 29 of file AtCSVReader.h.
|
inline |
Definition at line 33 of file AtCSVReader.h.
|
inline |
Definition at line 31 of file AtCSVReader.h.
|
inline |
Definition at line 34 of file AtCSVReader.h.
|
inline |
Definition at line 32 of file AtCSVReader.h.