This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Transforming a table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Transforming a table" Watch "Transforming a table" New topic

Transforming a table

alexandra kerr

Joined: Jun 05, 2010
Posts: 4
Hi! I'm trying to transpose a table, with 3 columns: identifier, date and value.
Identifier is a number that identifies the client, date is dd/mm/yyyy and value is a number 0 to 10.
So this is the initial table:

Identifier date value
1200 06/12/2009 5
1200 06/12/2009 6
1200 07/12/2009 4
1200 08/12/2009 9

I need to transform it in another table, in which all values of the same client identifier are in the same row: separated with a blank when they have the same date and values from different days are separated with a -1. The initial table is transformed in:

5 6 -1 4 -1 9 -1
The initial table is a .txt and the final one should also be one.

I'm new to java and I've been trying to solve it using java, please could anyone help..
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Hmmm quite a complex one Try breaking it in smaller pieces.

I don't know how good is your Java knowledge, but it would be probably best if you'd used a class to represent your rows. Possibly some sort of a collection to store them in, while you combine them together.

There are plenty of articles about writing and readnig form a file, so that shouldn't be a problem.



I no good English.
I agree. Here's the link:
subject: Transforming a table