Here is the modification :
function parseLineCSV(lineCSV) {
// parse csv line by line into array
var CSV = new Array();
// Insert space before character “,”. This is to anticipate ‘split’ in IE
// try this:
//
// var a=”,,,a,,b,,c,,,,d”;
// a=a.split(/\,/g);
// document.write(a.length);
//
// You will see unexpected result!
//
lineCSV = lineCSV.replace(/,/g,” , “);
lineCSV = lineCSV.split(/,/g);
// This is continuing of ‘split’ issue in IE
// remove all trailing space in each field
for (var i=0;i<lineCSV.length;i++) {
lineCSV = lineCSV.replace(/\s*$/g,””);
}
lineCSV[lineCSV.length-1]=lineCSV[lineCSV.length-1].replace(/^\s*|\s*$/g,””);
var fstart = -1;
//MODIFICATION START
var quotedStr = false;
var endQuotedStr = false;
for (var i=0;i<lineCSV.length;i++) {
//if we start a quoted string
if(!quotedStr && lineCSV.match(/^\s*”/))
{
quotedStr = true;
fstart = i;
}
//if we are going out of a quoted string
if(quotedStr && lineCSV.match(/”\s*$/))
{
endQuotedStr = true;
}
//if this piece of string is inside the quoted string and it is not the first part
// do concatenation
if (quotedStr && fstart < i){
lineCSV[fstart]=lineCSV[fstart]+”,”+lineCSV;
lineCSV=”-DELETED-“;
}
//we are out of this quoted string, resets default values
if(endQuotedStr)
{
quotedStr = false;
endQuotedStr = false;
fstart = -1;
}
}
//MODIFICATION END
var j=0;
for (var i=0;i<lineCSV.length;i++) {
if (lineCSV!=”-DELETED-“) {
CSV[j] = lineCSV;
CSV[j] = CSV[j].replace(/^\s*|\s*$/g,””); // remove leading & trailing space
CSV[j] = CSV[j].replace(/^”|”$/g,””); // remove ” on the beginning and end
CSV[j] = CSV[j].replace(/””/g,'”‘); // replace “” with ”
j++;
}
}
return CSV;
}