#pragma once
#include <fstream>
#include <sstream>
using namespace std;
class CSV{
public:
ifstream file;
string contents[256][256];
unsigned short width, length;
CSV(const char* name){
file.open(name);
width=0;
length=0;
string lines[256];
while(!file.eof()){
getline(file,lines[length]);
length++;
}
length--;
unsigned short tempwidth=0;
for(unsigned short i=0; i<=length; i++){
stringstream line;
line<<lines[i];
tempwidth=0;
while(line.good()){
getline(line,contents[tempwidth][i],',');
tempwidth++;
}
if(i==0)
width=tempwidth;
}
}
string Get(unsigned int row, unsigned int column){
if(row<1)
row=1;
else if(row>length)
row=length;
if(column<1)
column=1;
else if(column>width)
column=width;
return contents[column-1][row-1];
}
};