I have CSV file which contains 6 column separated by comma:
VendorCode, VendorName, Material, MaterialDescription, Reason, Quantity
I am able to retrieve data from each column except “Reason” column as it contains values in that column as:
Pitted, Rusty
( I mean comma separated values are there in that column)
(So Pitted value is inserted in “Reason “ arraylist & Rusty is inserted in “Quantity” arraylist For that particular line)
For eg: :
One row of csv file contains:
AA90,ABC LTD.,2.71E+11,ASSY/LAM`E'CE-MSSL-RINDER,"VisualCrack,B.H,Damage,Burr",330
DESIRED OUTPUT :
“pitty,rusted” should be treated as single string and stored in database
i have tried this
while ((thisLine = myInput2.readLine()) != null) {
String[] str = thisLine.split(",");
for(int j=0; j<str.length; j++) {
switch(j) {
case 0: DR_VendorCode.add(str[j]);//getContents()); break;
case 1:DR_VendorName.add(str[j]);//getContents()); break;
....
}
i1++;
}
}
for(int k=0;k<DR_VendorCode.size()+1;k++) {
String DR_VCODE=DR_VendorCode.get(k).toString();
String DR_VNAME=DR_VendorName.get(k).toString();
....
}
Here you go …
Output …
To handle 5th (actually any but only one) column with multiple embedded quotes …
Output …