posted 17 years ago
The CSV file is setup like this:
the beginning numbers before the colon is just my representation of the row number and is not part of the csv file.
----------------------------------- |
0:HEADER,DATE,OTHER STUFF |
1:string1,text1,another1,something1 |
2:string2,text2,another2,something2 |
3:string3,text3,another3,something3 |
4:string4,text4,another4,something4 |
5:string6,text5,another5,something5 |
----------------------------------- |
code snippet:
(firstly I open a DB connection and create the BufferedReader object etc)
(this is the code snippet that read the columns of the csv but i also want to read rows so that I can access a string (DATE) in row zero and the skip over once I have it and then populate my DB from row 1)
while((lineReader = in.readLine()) != null){
lineText = lineReader.split(",");
strDate = lineText[0][1].trim(); //I need to get this where
//it corresponds to the
//bold DATE in the csv file
strText = lineText[1].trim(); //this gets treated as a column and
//is inserted into DB table
// and continues till the end of the file
strSomething = lineText[3].trim(); //this gets treated as a column
//and is inserted into DB table
// and continues till the end of the file
(relevant sql goes here to update table)
I hope this make sense
The platform we are working on isn't very forgiving when adding new libraries and it is one of my job requirements to do this.
[ February 22, 2008: Message edited by: jacques du plessis ]