Hello, I am working on a program where I have a input file seperated by comma. I want to pull out the different columns and based on there values need to do some calculations and again generate output file with the result. I have to give Input file location, Customer name and output file location from command line and rows with the customer name given will be selected and operations will be performed only on those rows.
How can I achieve that? means how to extract columns info?
Sounds a bit like a school project.. so I'll try to give advice rather than a solution.
As I understand your problem, you got a (text) file which contains some data (a comma separated list) that needs to be computed. For example:
and for each column (i.e. (1,1,1), (4,3,3) and so forth) you need to perform an operation. An idea might be to 1) load each row in some kind of a datastructure (array, linkedlist ect.) and 2) perform the operation on each column.
Now, how do you extract column information? well, there are many ways.. how do you think you can extract it? What ideas do you have?
You need to "load" the file in memory: java.io deals with in/out.
try to solve the assignment by solving it in "small steps"
Try to 1. impl. a loadFile(String input_location) method which loads the file 2. impl. a printLines(File myFile) which prints all the lines in the file (hint: loop) 3. impl. the two method: - loadData(File myFile) which parses the lines in the file, and inserts all the elements in a datastructure (e.g. String array). Here you need to read a line, and then parse that string char by char. - printDataStructure() prints the datastructure that contains the data you just substracted from the file 4. Try to work on the transformations 5. Try to implement a writeResult() method which writes data to the output file.
Take a look at the links I posted earlier... this should get you started.