exporting calculated fields JBuilder

HI: there may not be many JBuilder users out there but here goes:
I am importing a csv file into JBuilder and adding a calculated column.
I now want to re-export the file...but the calculated field does not pass.
Is there a workaround for this?
In Java terms I guess it is importing, amending and exporting vectors?

Thanks!
Richard TeasdaleFinancial ControllerAsked:
Who is Participating?
 
for_yanCommented:

below id the Java program for re-writing file
(cjheck the attached files - the BarCode-orig.txt file was the input,
the BarCode-dest.txt file was the output of this program).

Paste the contents of this code to the file
called RewriteCSVFile.java

Then,  I hope you have JDK (Java Development Kit) installed.
If so, go to to Dos command line
put this .java file and your input file (it should be called
BarCode-orig.txt) into one folder
go to that folder in the DOS window
and type

javac RewriteCSVFile.java

and after it compiles, say

java RewriteCSVFile

the new file called BarCode-dest.txt
should appear in the same folder - check with
the editor that it has an additional column you wanted.
 






import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.PrintStream;

public class RewriteCSVFile {
    public static void main(String[] args) {

        try {
            BufferedReader br = new BufferedReader(new FileReader("BarCode_orig.txt"));
            PrintStream psout = new PrintStream(new FileOutputStream("BarCode_dest.txt"));
            String buff = null;
            while((buff=br.readLine()) != null){
                String [] ss = buff.split(",");
                psout.println(buff + ",\"E:\\Data\\custpics\\" + ss[3].substring(ss[3].length() - 2) + ".jpg\"");



            }

            br.close();
            psout.close();

        } catch(Exception ex){
            ex.printStackTrace();
        }

    }
}

Open in new window



BarCode-dest.txt
BarCode-orig.txt
0
 
for_yanCommented:
>I am importing a csv file into JBuilder

I'm not sure I understand - do you mean that you are reading CSV file
by your java program which you run in JBuilder.

Could you, please, you elaborate?
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Of course.
I have a csv file, output from a database. I need to add a column to the file. This column is calculated as being the last 2 digits of one of the other columns; so column50  needs to be 'the last 2 digits of column 4'.
The file then needs to be passed forward for processing by some label printing software.

I can - and am - doing this all within the (foxpro) database but would like to be able to adjust the file after export.   I have tried c++ and got hopelessly puzzled!  I have tried Java (NetBeans) and just as bad. C# has got me nowhere . VB I have not looked at. I have found a perl solution but not tried it.
JBuilder  has got me further than anything else; I can read the file; I can add a calculated column. But when I try to output the file then the calculated column does not output!
Trying to understand  the underlying process keeps leading me to vectors but in c++ at least I am never able to convert a 'data' type vector to string. Maybe Java/ Jbuilder has the same issue?
 As you see I don't mind how I solve the problem, just that I do!
Thanks for your time.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
for_yanCommented:

Manipulations with csv file are not depndendt on NetBeans or JBuilder - they are perforemd by java program
which can be executed either using one of these IDE or directly from the command line.
Post a small snippet of your CSV file (just a few lines) and show how it needs to be changed - I'll try
to help you with Java code to re-write the file. Then you can either use JBuilder or NetBeans or command line
to execute this Java program.
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Thank you very much! Please remember 2 things; I am a newbie; and I need to learn!
I attach the file from the database. Please note that what  I want is already done. It is for my understanding that I want to recreate the process outside the database.
The file has 2 lines. Note the end of the first line has the field "E:\Data\custpics\81.jpg" . This is calculated directly from the  the last 2 digits of fourth field, 781781.
A final note; this I am doing at home, not here at work. I may not be able to look at any solutions until much later.
Thanks again.

BarCode.txt
0
 
for_yanCommented:
So you want to add the last column based on the last two digits of the fourth column?
Original file would be the same without the last column - correct?
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Yes, please!
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Thank You Very Much!
Excellent, helpful response.
One question, if you don't mind. You chose Java. Is this because you use Java, because I asked for it, or because it was best for this? I am trying to learn when to use Java; when c#, when c++, when vb, etc.
You are obviously an expert. You must find that  people don't ask 'do me a Java program'; they ask 'sort my problem.' I am keen to learn why you chose Java.
Don't reply if you don't want to.
Thanks again.
0
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.

All Courses

From novice to tech pro — start learning today.