66bool AutoDecodeCSV(
const wxString& aInput, std::vector<std::vector<wxString>>& aData )
69 bool trimCells =
true;
70 bool skipCommentLines =
true;
71 bool skipEmptyLines =
true;
72 char commentPrefix =
'#';
76 if( aInput.find(
'\t' ) != std::string::npos )
81 std::istringstream inputStream( aInput.ToStdString() );
83 rapidcsv::Document doc( inputStream, rapidcsv::LabelParams( -1, -1 ),
84 rapidcsv::SeparatorParams( delimiter, trimCells ), rapidcsv::ConverterParams(),
85 rapidcsv::LineReaderParams( skipCommentLines, commentPrefix, skipEmptyLines ) );
90 size_t rowCount = doc.GetRowCount();
91 size_t colCount = doc.GetColumnCount();
93 for(
size_t i = 0; i < rowCount; ++i )
95 std::vector<std::string> docRow = doc.GetRow<std::string>( i );
96 std::vector<wxString>& outRow = aData.emplace_back( colCount );
98 for(
size_t j = 0; j < std::min( colCount, docRow.size() ); ++j )
99 outRow[j] = wxString::FromUTF8( docRow[j] );
103 return !aData.empty() && aData[0].size() > 0;
bool AutoDecodeCSV(const wxString &aInput, std::vector< std::vector< wxString > > &aData)
Try to guess the format of a T/CSV file and decode it into aData.