Sama Mushtaq

Greenhorn
+ Follow
since Apr 02, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sama Mushtaq

@jayesh thanks..will do..
8 years ago
Actually there are multiple entries for a date , i need a way to sum all the entries so that for a specific date there is just one number..
8 years ago
its a 1:1 mapping to the .csv file ..all the columns that are present in the file are fields in the db so if the value is a int in the file its will have an int type field in the db..
8 years ago
for eg i have to plot a line graph for a specific parameter..i need a query that will extract all the data values in the specific given date range and add the various values pertaining to a specific date..
eg:date range= 04/01/2012--04/30/2012
there are multiple entries for the each date..
8 years ago
actually its all numerical data values hence JFreeChart..i am trying to plot thge data as a line graph across the XYaxis,,so basically i will have to end up summing all the data for a date range range and then display it..
8 years ago
the files are .csv files whose values are loaded in the db..there are many types of files that have common columns in the db..i have to graph using JFreeChart..
8 years ago
How do i compare two parameters of multiple files in mysql and chart the results to a graph.what is the query for that?
8 years ago

So im working on a project where im supposed to dynamically load the contents of a .csv file into the database.I have been hard coding the path of the file till now like

inserted = insertFromFile("C:/Users/Student/Desktop/Book1.csv",connection, "customer");

however now i have to read multiple files from a folder and integrate the program with a GUI. I have 2 questions:

a)how do i read multiple files from a folder b)how do i retrieve the path of a file for the insert statement

any help is appreciated.

Thanks!
8 years ago
thanks this is helpful..i will try to implement this in my code..
my problem at this point of time is that i dont understand how to insert the values in a pre-defined table in the db.the code displays the values on the console so should i store it in an object/intermediate structure or simple embed the code for parsing in the JDBC?
@ Tim i already wrote the code for that and have included that in a previous post..
the type of the files in the file properties is "Microsoft Excel Comma Separated Values File (.csv)"..it opens with MS-excel..
the files that Im working on are excel worksheets.I tried uploading one as an example but apparently I cant attach a .csv file to my reply.
i was writing the code specifically for comma separated values hence the code.
this is the original program that i use to parse and it works well: however now im trying to insert the values in the db instead of displaying them on the console
package database;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.StringTokenizer;


public class MySQLConnect {

/**
*
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String fileName="C:/Users/Sama/Desktop/dod001_fragmented_drive_20120130.csv";
try {
BufferedReader br = new BufferedReader( new FileReader(fileName));
String strLine = null;
StringTokenizer st = null;
int lineNumber = 0, tokenNumber = 0;

while( (fileName = br.readLine()) != null)
{
lineNumber++;

//break comma separated line using ","
st = new StringTokenizer(fileName, ",");

while(st.hasMoreTokens())
{
//display csv values
tokenNumber++;
System.out.println("Line # " + lineNumber +
", Token # " + tokenNumber
+ ", Token : "+ st.nextToken());
}

//reset token number
tokenNumber = 0;

}
}




catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}