vendredi 29 janvier 2016

regex pattern to extract empty field from CSV file

I have a csv file that needs to be read into Matrix. Right now i have regex pattern

regex pat { R"(("[^"]+")|([^,]+))" }

Right now it chooses between sequences that are between quotes and anything that is not comma. The file contains data from the survey that has questions with yes no answers. If you answer "no" you do not need to answer to some related questions. Therefore i get some sequences in file like this: ":,,,,,,,," Wheres each two commas mean an empty field. But i would like to remain the row as an equally numbered array. It seems that it would be easyer to later navigate through matrix to get information. So i would have to extract these empty fields between the commas. I could not find a regex pattern for empty sequence. Is regex pattern a proper way for solving this issue?

Aucun commentaire:

Enregistrer un commentaire