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}');
 fi

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

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?

Recommended Answers

All 2 Replies

Member Avatar for 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.

Member Avatar for iamthwee

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.