aspose file tools
The moose likes Java in General and the fly likes How to replace the value in a row with previous row value if it is null or 0. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to replace the value in a row with previous row value if it is null or 0." Watch "How to replace the value in a row with previous row value if it is null or 0." New topic
Author

How to replace the value in a row with previous row value if it is null or 0.

n jay
Greenhorn

Joined: Dec 29, 2009
Posts: 28
Hye..

How to take the value in the first row and store it in the second row. for example; lets say there is a table with 2 rows.

table

column 1 | column 2 | column 3 | column 4
A 15 9 8
B 12 0 0

if you see there is this row B with value 12, 0 ,0. but i don't want the value 0 in that column and i want to replace the column that has value 0 with value in row A.
How can i do that in java??


thanks in advance,
njay
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8576

TellTheDetails

What table is this? JTable? HTML? Database?


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
n jay
Greenhorn

Joined: Dec 29, 2009
Posts: 28

hye..thanks for the reply.

It is a html table.

-nj-
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16815
    
  19

n jay wrote:
It is a html table.



Still need more info. Java doesn't have a common way to manage or process HTML, so we really don't have any idea of the API / Library / Framework that you are using.

Put yourself in our shoes, do really think that you have given us enough info, for us to know what you are talking about?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
n jay
Greenhorn

Joined: Dec 29, 2009
Posts: 28
Put yourself in our shoes, do really think that you have given us enough info, for us to know what you are talking about?


My bad..Sorry.

The table is actually generated from csv file that contain all the data for that table.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8576

You really should read Henry's reply carefully and provide sufficient information.
Still need more info. Java doesn't have a common way to manage or process HTML, so we really don't have any idea of the API / Library / Framework that you are using.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16815
    
  19

n jay wrote:
The table is actually generated from csv file that contain all the data for that table.



Since it is clear that you want to keep this at a very high level, here is the answer...

Assuming that the CSV data is match row per row to the HTML data, then either (1) have a variable that holds the previous row of the CSV, or (2) have a variable that holds the previous row of the HTML data. Prior to generation of the HTML data row, do a quick loop through the different fields, and substitute the values from the previous data variable (if current is null or zero). Prior to going to the next row (using a loop), make sure you transfer the current data to the previous variable.


And this solution will likely work with any programming language, any data structure to be used in processing, any API that can be used to load and process the CSV, and any engine that can generate the HTML.

Henry
n jay
Greenhorn

Joined: Dec 29, 2009
Posts: 28
thank you henry.

But could you show some example on it..

The thing is that what do you really need to know because i have no idea...sorry for being not so helpful...

-nj-
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16815
    
  19

n jay wrote:
The thing is that what do you really need to know because i have no idea.


You are asking for a solution and / or examples for a specific issue, when it is painfully clear that you don't even have a high level knowledge of the issue at hand. I recommend that you forget this question entirely, and go back to investigate the system / code that you currently don't know very much about.

You can't get to a solution, if you don't know the problem. And you can't know the problem, if you don't know how stuff works. To be blunt (and hopefully without offense), at this point, you sound like what a non-technical manager would do, in trying to help his technical reports, in solving the problem.


Apologies. And feel free to ignore.

Henry
n jay
Greenhorn

Joined: Dec 29, 2009
Posts: 28
you don't even have a high level knowledge of the issue at hand.


Not being rude but if i have high level knowledge surely wont ask for explaination...


And Offence taken...Thank you for being such a helpful..



-nj-
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16815
    
  19

n jay wrote:
Not being rude but if i have high level knowledge surely wont ask for explaination...


"high level" knowledge means being able to explan something at a very basic level. It doesn't mean knowing something. Thinking of being in an airplane at 10000 feet and looking out the window. And I asked for for an explanation. Your knowledge will just be what you see, at a very high level, and for most cases, not very useful. But it is better than nothing.

And I am not refering to knowledge of the technology, I am refering to knowledge of your own system / issue. If you don't know it, how the heck are total strangers, who never looked out your window going to know it?

n jay wrote:And Offence taken...Thank you for being such a helpful..


Again sorry. But I thought you needed it.

Henry
n jay
Greenhorn

Joined: Dec 29, 2009
Posts: 28
n jay wrote: And Offence taken...Thank you for being such a helpful..


Actually no offence taken.....Sorry ya.


Again sorry. But I thought you needed it.


yea, i guess i needed it...Thanks ya henry...


-nj-
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to replace the value in a row with previous row value if it is null or 0.
 
Similar Threads
HTML table - net value print
JTreeTable - tree of DefaultMutableTreeNodes
Table model in swings
Cell renderer for different JComboBox's in same column?
Please Help in sorting JTable on multiple column.