hi all,
I have a csv file and I want to insert the csv file into the database columns consist of date,description1,description2,amount1,amount2,narration..
but the problem is the narration is coming in second line in csv file due to which the data is not getting inserted into the database.
so how to append the narration into the first line,I have enclosed the demo format of csv file and a code to read the csv file..
myFile.csv file:
code to read the csv file:
<%@ page import="java.io.*"%>
<html>
<body>
<%
String fName = "c:\\csv\\myfile.csv";
String thisLine;
int count=0;
FileInputStream fis = new FileInputStream(fName);
DataInputStream myInput = new DataInputStream(fis);
int i=0;
%>
<table>
<%
while ((thisLine = myInput.readLine()) != null)
{
String strar[] = thisLine.split(",");
for(int j=0;j<strar.length;j++)
{
if(i!=0)
{
out.print(" " +strar[j]+ " ");
}
else
{
out.print(" <b>" +strar[j]+ "</b> ");
}
}
out.println("<br>");
i++;
}
%>
</table>
</body>
</html>