I tried some corrections mentioned in other answers, but they did not affect my conclusion. I did not plan to use the spirit of enhancement, as I am not sure if this is the best option for my needs. Also, such a post is not related to the quoted material, which contains commas, which is my last problem to solve at this stage.
This is a C ++ program. I am using a CSV file for input. This file provides print functions; each entry has 23 values (columns). When I output rawdata [22], I expect to see the last record of the first dataset. Instead, I see the last entry (application), followed by the first entry (2055) of the next print. When I open it in a hex editor, I see that the two words are separated by a "." and the hexadecimal character is 0a. I tried setting \ r, \ n, \ r \ n as delimiters, but they do not work. I cannot use "," as a separator, because it is used inside strings, I tested it to see if it will work for my problem anyway, and it is not. How to separate these values?
CONCLUSION:
Petitioned
2055
SAMPLE INPUT:
SpeciesID, Kingdom, Phylum, Class, Order, Family, Genus, Species, Authority, Infraspecific rank, Infraspecific name, Infraspecific authority, Stock / subpopulation, Synonyms, Common names (Eng), Common names (Fre), Common names (Spa) , Red List status, Red List criteria, Red List criteria version, Year assessed, Population trend, Petitioned
2055, ANIMALIA, CHORDATA, MAMMALIA, CARNIVORA, OTARIIDAE, Arctocephalus, australis, "(Zimmermann, 1783)" ,,,,, Arctophoca australis, South American Fur Seal, Otarie fourrure Australe, Oso Marino Austral, LC ,, 3.1,2016 , increasing, N
41664, ANIMALIA, CHORDATA, MAMMALIA, CARNIVORA, OTARIIDAE, Arctocephalus, forsteri, "(Lesson, 1828)" ,,,,, Arctocephalus australis subspecies forsteri | Arctophoca australis subspecies forsteri, "New Zealand Fural Seural Seal, Black Fur Seal, Long-nosed Fur Seal, South Australian Fur Seal ",,, LC ,, 3.1,2015, increasing, N
my code is:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main() {
string line;
vector<string> rawdata;
ifstream file ( "/Users/darla/Desktop/Programs/seals.csv" );
if ( file.good() )
{
while(getline(file, line, '"')) {
stringstream ss(line);
while (getline(ss, line, ',')) {
rawdata.push_back(line);
}
if (getline(file, line, '"')) {
rawdata.push_back(line);
}
}
}
cout << rawdata[22] << endl;
return 0;