This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Analyze contents of CSV file  RSS feed

 
Justin Robbins
Ranch Hand
Posts: 121
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I want to create a method which reads in a CSV file and then correlates only two specific columns of the spreadsheet.

Here is a link to the CSV: http://imgur.com/XaV4Gxc

it goes to 399 lines.

These are for traffic stops data. What I want to do is correlate the two columns of hour of stop and gender, but I have no idea how to do this and single them out.

I want to have a method which after calculating/correlating the two columns would essentially tell the user: "the best time to drive as a female is _____" and "the best time to drive as a male is____"

then make an inverse method which tells the user: "the worst time to drive as a female is____" and "the worst time to drive as a male is____"

How possible is this method for a beginner? how would this be created? where do I start. If I could have some steps that would be wonderful.

Thank you
 
Stevens Miller
Bartender
Posts: 1444
30
C++ Java Netbeans IDE Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Justin, you don't really need a Java program to do this. In fact, writing Java code might be much harder than some of your other options.

You can use the data filtration tools all spreadsheets have to extract only the F or the M rows, then simply do a statistical analysis on your hour of stop. Try drawing a histogram. If the distribution looks at all bell-shaped, compute the average time of the stop and maybe the mode. There are a variety of ways to approach the analytical part of this, but I really don't think you will need more than the functions spreadsheets provide to make use of any of them.
 
Justin Robbins
Ranch Hand
Posts: 121
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I want to write a method like this how would it go? just curious as to how to set this up or where to begin. Should I round the times to something, or use mode.
 
Stevens Miller
Bartender
Posts: 1444
30
C++ Java Netbeans IDE Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I shouldn't mislead you on this one: I'm betting there's an existing class in the SE library that can parse CSV files for you, but I'm not the guy to tell you what it is or how to use it (because I don't know ). Maybe one of the other regulars who is familiar with it can chime it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stevens Miller wrote:I'm betting there's an existing class in the SE library that can parse CSV files for you


There isn't. But there are plenty of 3rd party libraries to do so (such as this).

But you shouldn't have all of this in one method. Rather, break the problem down into steps. For example, a method or class to take the CSV file and deserialize it into a List of beans that contain the information for each row. Any analysis of the data should be separate from the parsing process.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!