I am planning to modify the file format so that each field should be enclosed in by double quotes mandatory "A","Field1","Field2","Field3","Fi"el,d","Fi""eld", I want the separator to be combined i.e to be “, (double quotes followed by comma) how do i change the below split command to include two separator “, (double quote and comma) together line.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)",15);
I am planning to modify the file format so that each field should be
Share
This would do it:
You’d need to trim the extra quotes that aren’t removed by the split. You could also consider splitting on
"\",\""instead.However, instead of reinventing the wheel, I’d suggest that you try to find an existing CSV reader for your platform. It will be better and faster and a lot less work.