New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for access original data for advanced process and load csv from string. #25
Comments
Hi @akeyliu - thanks for your input / suggestions.
|
I realise that the support for these use-cases are not currently clearly documented, so at least I could try improve the documentation for that. |
Thanks for your reply and explain!
|
Hi @akeyliu - thanks for the reply and the suggestions.
I will proceed to close this issue. |
Thanks for your contribution for rapidcsv, and I'm using it in my project.
There are some new requirement from me for advanced usage for rapidcsv, and I hope it can help on improving rapidcsv.
I suggest to add another function to load csv, currently ,there are 2 function to call ReadCSV, one is the csv filename in string, another is the istream. And there is another usally condition to load CSV from string object, which I think need to add it to rapidcsv for user convinience.
I add 2 new functions to access the original csv data wihch is mData in rapidcsv which can provide more powerful access to original data. and I using the follow code.
/**
*/
std::string GetCellData(const size_t pColumnIdx, const size_t pRowIdx) const
{
const ssize_t columnIdx = pColumnIdx + (mLabelParams.mRowNameIdx + 1);
const ssize_t rowIdx = pRowIdx + (mLabelParams.mColumnNameIdx + 1);
return mData.at(rowIdx).at(columnIdx);
}
/**
*/
std::string GetCellData(const std::string& pColumnName, const std::string& pRowName) const
{
const ssize_t columnIdx = GetColumnIdx(pColumnName);
if (columnIdx < 0)
{
throw std::out_of_range("column not found: " + pColumnName);
}
const ssize_t rowIdx = GetRowIdx(pRowName);
if (rowIdx < 0)
{
throw std::out_of_range("row not found: " + pRowName);
}
return GetCellData(columnIdx, rowIdx);
}
The text was updated successfully, but these errors were encountered: