You need to sign in to do that
Don't have an account?

Need to remove and merge data in between 2 consecutive quotes into one
I am reading csv string and placing the values into appropriate fields in Salesforce Objects.
But for below scenario I am facing error:
Consider csv Line has 123,56,124,45,45,2548,3356 --this works fine with 6 columns into 6 fields
If Input has string/comma like 123,56,124,45,45,"2,548","3,356" We are getting an error of invalid integer "2
Need to merge data between two "" into one without spaces just like the former
But for below scenario I am facing error:
Consider csv Line has 123,56,124,45,45,2548,3356 --this works fine with 6 columns into 6 fields
If Input has string/comma like 123,56,124,45,45,"2,548","3,356" We are getting an error of invalid integer "2
Need to merge data between two "" into one without spaces just like the former
Thanks,
csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
string[] csvHeaderData = csvFileLines[0].split(',');
Month1=csvHeaderData[7];
Month2=csvHeaderData[8];
Month3=csvHeaderData[9];
Month4=csvHeaderData[10];
Month5=csvHeaderData[11];
Month6=csvHeaderData[12];
/*if(Month1.contains(' ')){
Month1= Month1.substring(0, Month1.indexOf(' '));
}
if(Month2.contains(' ')){
Month2= Month2.substring(0, Month2.indexOf(' '));
}
if(Month3.contains(' ')){
Month3= Month3.substring(0, Month3.indexOf(' '));
}
if(Month4.contains(' ')){
Month4= Month4.substring(0, Month4.indexOf(' '));
}
if(Month5.contains(' ')){
Month5= Month5.substring(0, Month5.indexOf(' '));
}
if(Month6.contains(' ')){
Month6= Month6.substring(0, Month6.indexOf(' '));
}*/
for(Integer i=1;i<csvFileLines.size();i++){
Opportunity_Estimate__c oeobj = new Opportunity_Estimate__c() ;
string[] csvRecordData = csvFileLines[i].split(',');
oeobj.Opportunity_AX_ID__c = csvRecordData[0] ;
oeobj.Comments__c = csvRecordData[13];
}