cancel
Showing results for 
Search instead for 
Did you mean: 

Parse

Former Member
0 Kudos

Anyone could help me?

After uploading a CSV file, parsing it with StringTokenizer and displaying it in a table, how can i catch a value of a cell so to compare it to another?

Thanks

PS: I heard something about comma separated list. What´s the diference between this and comma separated values?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If you could help me with another thing. how can i make the addiction of various values of a columm, that I get from the tableview?

eg. I would like to present in a textarea(for example) the total of my frist columm.

I´m going to that a look at the reward point´s again!!

darrell_merryweather
Active Contributor
0 Kudos

You could do something like

<code>

try{

int value1 = java.lang.Integer.parseInt(TableView.getValueAt(<row>,<column>).getValueAsString());

int value2 = java.lang.Integer.parseInt(TableView.getValueAt(<row>,<column>).getValueAsString());

int newValue = value1 + value2;

}

catch(NumberFormatException e){

//Do Something as the value in the string is not a number

}

</code>

I hope this helps

D

Former Member
0 Kudos

Hi,

with the help of a friend, my code...

int total = 0;

for(int i =1; i<=tabResultado.getRowCount();i++) {

String s = tabResultado.getValueAt(i,"Valor Monetário").getValueAsString();

int parcela = 0;

try{

parcela = new Integer(s).intValue();

}catch(Exception e){}

total = total + parcela;

}

the problem is that it only "catches" values like 1;2;3 and not 1.4;0.4.

Can you help me?

Former Member
0 Kudos

Hi Virginia,

maybe it's a very stupid answer, but why don't you try with something like this?

float total = 0;

for(int i =1; i<=tabResultado.getRowCount();i++) {

String s = tabResultado.getValueAt(i,"Valor Monetário").getValueAsString();

float parcela = 0;

try{

parcela = new Float(s).floatValue();

}catch(Exception e){}

total = total + parcela;

}

Cheers

Roberto

Former Member
0 Kudos

Grazie Roberto and Darrell for your help

Answers (1)

Answers (1)

darrell_merryweather
Active Contributor
0 Kudos

If you are using the TableView HTMLb element then you can use the getValueAt(int row, String columnName) method, if you are using the HTML table, i.e. <tr><td></td></tr>, then you would have to assign ids or names to the tags and use javascript to compare the values.

A comma separated list is basically the same as the CSV file as far as I am aware and would be processed in the same way.

I hope this helps

Darrell