This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes comparison b/w 2 files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "comparison b/w 2 files" Watch "comparison b/w 2 files" New topic
Author

comparison b/w 2 files

Sama Mushtaq
Greenhorn

Joined: Apr 02, 2012
Posts: 19
How do i compare two parameters of multiple files in mysql and chart the results to a graph.what is the query for that?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What's the connection between files and MySQL? What are those "parameters"? What should the output of the comparison be - can you give an example? And how should it be graphed?
Sama Mushtaq
Greenhorn

Joined: Apr 02, 2012
Posts: 19
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..
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
OK, so the file contents are in the DB; presumably in a varchar field?

What kind of graph do you have in mind? How would it show differences between the files?

JFreeChart is probably a bad choice; it's mostly geared towards numerical or date/time data.
Sama Mushtaq
Greenhorn

Joined: Apr 02, 2012
Posts: 19
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..
Sama Mushtaq
Greenhorn

Joined: Apr 02, 2012
Posts: 19
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..
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
You still haven't said how the file contents are stored in the DB. I assumed the file contents were unstructured in a varchar field; if that's the case, then it would be extremely cumbersome to extract specific data points via SQL. The solution would be to load them into memory, and then to use one of the numerous freely available CSV libraries to obtain an in-memory representation of the CSV.
Sama Mushtaq
Greenhorn

Joined: Apr 02, 2012
Posts: 19
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..
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
So you need a way to retrieve all the values that originate in one file, and all the values that originate from the other file, and then check for "differences", however those are defined. What constitutes a "difference" - two values not being exactly identical? If so, what should be plotted on the graph? Remember, we have no idea how your data is structured.
Sama Mushtaq
Greenhorn

Joined: Apr 02, 2012
Posts: 19
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..
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2271
    
  28

Sama, You need to learn something called Structured Query Language (SQL). You can use SQL to retreive data from MYSQL and can also ask MYSQL to aggregate data for you. For example, you need to use a SQL statement like this




I suggest that you pick up a good book on SQL
Sama Mushtaq
Greenhorn

Joined: Apr 02, 2012
Posts: 19
@jayesh thanks..will do..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: comparison b/w 2 files
 
Similar Threads
Need to Convert Documents to HTML
WA #1.....word association
Componentized logic in views - what to use.
ClassNotFoundException in Jsp Precompilation
How to create a war file.