[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:Ankit,
Welcome to CodeRanch!
How many students are in the file? Unless it is an extremely large number, your best bet might be to load the file into a ConcurrentMap (using one of those libraries) and doing your parallel processing in Java.
Don't need a framework, just read the file line by line and split each line. For validation, check the values in the split array.
Ankit Gohil wrote:Do they actually read a line at a time from the file and store it in some buffer area. How is it actually processed. Can you give me in-depth info on this ?
Ulf Dittmer wrote:
Ankit Gohil wrote:Do they actually read a line at a time from the file and store it in some buffer area. How is it actually processed. Can you give me in-depth info on this ?
The libraries are all open source, and not big in size - might as well just look at the source if you're interested. I have always just used them, and never worried about how they work under the hood. I'd be surprised if any of them read the entire file into memory instead of line by line, as it would be an obvious and needless inefficiency.
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
K. Tsang wrote:Hello Ankit
I have used OpenCSV a few times. Regarding the library reading line by line or all at once, from my observation it's line by line. Use OpenCSV as example. Its API has 2 read() methods
public String[] read(Reader file);
public List<String[]> read(Reader file);
You may have guessed the method returning List<String[]> reads the entire file into memory. This option has its good and bad points. Good point it you can easily go to the footer at the end of the file instead of reading line by line until the end. The bad thing is large files will cause OutOfMemoryError.
The threading issue I'm not aware such libraries has what you want. Normally if there are many files to process, one file per thread. What you do in the thread (eg to spawn new sub-threads) is up to you.
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
Ankit Gohil wrote:So this mean I need to write my own code for checking it. Hope some day these libraries include this functionality or maybe I can provide them with one
Ulf Dittmer wrote:I would imagine that the code throws an exception, or some error code, if the file is not actually properly formatted CSV.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Stuart A. Burkett wrote:
Ankit Gohil wrote:So this mean I need to write my own code for checking it. Hope some day these libraries include this functionality or maybe I can provide them with one
I think Ulf's reply indicated the exact opposite of that
Ulf Dittmer wrote:I would imagine that the code throws an exception, or some error code, if the file is not actually properly formatted CSV.
It's not what your program can do, it's what your users do with the program.
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|