Zookeeper
///
/// Split the string with commas (,)
/// If a field contains a comma (Note: fields containing a comma must be referenced in double quotation marks), splice the fields.
/// Remove the double quotation marks of the field
///
///
///
Private static string [] SplitStringWithComma (string splitStr)
{
Var newstr = string. Empty;
List SList = new List ();
Bool isSplice = false;
String [] array = splitStr. Split (new char [] {','});
Foreach (var str in array)
{
If (! String. IsNullOrEmpty (str) & str. IndexOf ('"')>-1)
{
Var firstchar = str. Substring (0, 1 );
Var lastchar = string. Empty;
If (str. Length> 0)
{
Lastchar = str. Substring (str. Length-1, 1 );
}
If (firstchar. Equals ("\"")&&! Lastchar. Equals ("\""))
{
IsSplice = true;
}
If (lastchar. Equals ("\""))
{
If (! IsSplice)
Newstr + = str;
Else
Newstr = newstr + "," + str;
IsSplice = false;
}
}
Else
{
If (string. IsNullOrEmpty (newstr ))
Newstr + = str;
}
If (isSplice)
{
// Add a comma that is lost during split.
If (string. IsNullOrEmpty (newstr ))
Newstr + = str;
Else
Newstr = newstr + "," + str;
}
Else
{
SList. Add (newstr. Replace ("\" "," "). Trim (); // remove double quotation marks and spaces
Newstr = string. Empty;
}
}
Return sList. ToArray ();
}