process large csv file with java

Posted on 2013-09-21
Medium Priority
Last Modified: 2013-10-07

I have csv files with just one column and maybe 1'000'000 lines, like this:


(basically wordlists)

I would like to open these files with a swing form (netbeans) - i.e. i need an "open" button, after clicking it i select the file, and then the file gets processed line by line (i process the content of each line and query some mysql stuff for each line) until the end of the file is reached.

thanks for some input / sample code on how to do this!
Question by:netslt
  • 2
  • 2
  • 2
LVL 86

Accepted Solution

CEHJ earned 750 total points
ID: 39512096
You can use a BufferedReader. Calll readLine on it in a loop

Author Comment

ID: 39512114
Could you pls give me a bit of sample code?

LVL 27

Assisted Solution

mrcoffee365 earned 750 total points
ID: 39512181
CEHJ is right.  A simple search will find many examples using BufferedReader and readline .

Oracle has an excellent Java tutorial you could use:
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

LVL 86

Expert Comment

ID: 39551572
LVL 27

Expert Comment

ID: 39552518
CEHJ gave you the right answer within minutes.  You might not be aware that an A grade does not cost you anything, but gives more points to the expert.  Plus, of course, you got the right answer, which should be graded as an A.  Please consider that the next time you try to award points to the people who are helping on the site.

Author Comment

ID: 39552553
Hello CEHJ and mrcoffee356

I am really sorry if I made a rating that is not the way that it should have been done.

If I could change the rating it I would (dont see any possibility to do this - if there is, pls let me know)

My thoughts were that an answer with sample code (as I asked in the question) would have been an A, and a general answer not really an A.

But of course that was not right thinking.

Also I was not sure on the distribution of points. Both answers where of help - so I distributed the points evenly.

Maybe I should have given all points to CEHJ or at least more because he was faster? Here I was just unsure and wanted to honor both efforts.

Again: I am sorry!

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question