I guess some of you might have written some utility programs that allow
you to convert a CSV file to another CSV file with fewer columns and
having some field values mapped according to some rules.
I am looking for a similar solution to help my poor colleague to
simplify his daily manual work to reformat several CSV files using
excel.
Rhino - 16 Apr 2005 18:05 GMT
> I guess some of you might have written some utility programs that allow
> you to convert a CSV file to another CSV file with fewer columns and
[quoted text clipped - 3 lines]
> simplify his daily manual work to reformat several CSV files using
> excel.
First, I'm not really sure what you mean by converting a CSV file to another
that has fewer columns and has some field values mapped according to some
rules. It's a very vague description of what you want and I don't get a
clear picture of what you mean. A simple example of what you mean would be
useful.
Second, I don't see anything in the description of the problem that
especially lends itself to Java, as opposed to the umpteen other programming
languages out there. In fact, it sounds like more of a batch utility to me
than a Java program. If I were going to write something like that, I might
be more inclined to use a BASH script or REXX or one of the Linux utilities.
There are many script-type languages out there that do a very good job with
this kind of task and carry a lot less overhead than Java.
You might get a better answer on the newsgroups associated with those
languages.
Rhino
Betty - 16 Apr 2005 18:46 GMT
> I guess some of you might have written some utility programs that allow
> you to convert a CSV file to another CSV file with fewer columns and
[quoted text clipped - 3 lines]
> simplify his daily manual work to reformat several CSV files using
> excel.
It is probably easier in Perl or Python, but if you want to
use Java you can read the file a line at a time using something like
while ((line = in.readLine()) != null)
then split the string into smaller strings
String columns[] = line.split(",");
// your magic goes here
then output the columns you want
out.print(columns[0]+","+columns[1]+"," .....
out.println();
Robert - 17 Apr 2005 04:11 GMT
Check out the Ostermiller java utilities. He has a CSV parser or
printer or something and a special excel compatible one as well, I
think.
http://ostermiller.org/utils/