• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
n jay
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TellTheDetails

What table is this? JTable? HTML? Database?
 
n jay
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hye..thanks for the reply.

It is a html table.

-nj-
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
n jay
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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-
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!