So I have text file that I need to reformat so I can import it into a spreadsheet. I was originally going to do this in Java, since I had a vague familiarity with it, but there are few good classes in Java that are useful for text processing, and the solution in Java would be more complex than it needs to be.

This is my input file: store-orders.txt

Items purchased by TexasStore:
Orders: 7 Unique: 4 OutofStock: 0
StockID DepartmentID Instances
34.34 12 10
34.3 12 6
2.75 6 55

Items purchased by FloridaStore:
Orders: 6 Unique: 6 OutofStock: 1
StockID DepartmentID Instances
34.27 12 78
33.3 6 27
5.75 7 33

I need my output to be:

TexasStore 34.34 12
TexasStore 34.3 12
TexasStore 2.75 6
FloridaStore 34.27 12
FloridaStore 33.3 6
FloridaStore 5.75 7

This way I can import it into excel and sort the other values.

What programming/scripting language do you think would be most suited for this kind of text formating?

If I am going to learn a programming language to solve 1 problem, I would like to select one with native support for this kind of thing.

Here is a pseudo example of what I want to do:

read store-orders.txt

while (next.line() != null) {

 if ((grep Store $line) == true)
 $store = (awk '{print $4}');

 if ($line == ^number)
 print.line ($store $1 $2);

You would think something that is 6 lines of pseudo code would not require pages of Java but it isn't the kind of problem Java is intended to solve.

So about how difficult would a problem like be with VB.NET?

10 Years
Discussion Span
Last Post by iamthwee

You could do it with both java and vb.net.

In java you would write it to an excel file using jexcel API .

In vb.net you could either use com objects or ado.net to connect to the excel file.

Using ado.net would be preferred as you don't necessarily need the microsoft excel installed, which is a prerequisite if you are using com objects.


Ok I missed your point, I thought you were asking how you would write to an excel file in either java or vb.net.

It seems like you are just asking a basic file parsing question. The answer to this is that java and vb.net are both equal.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.