View Full Version : Removing redundant column in arrays

09-16-2011, 10:29 AM

I read a lot of data from excel sheets into JS arrays.

I have a situation where i have name, hours, product id and other few entries.
I have all these details as array in array concept.

eg. array.push(new Array(name,hours,pid,price,place))

Redundant entries that include same names,pid, places will be found in the array.

My prob is to sum up all the hours of the records that belong to same name and product id and store the unique records in one array and ofcourse the hours column sumed up.

name pid hours place
aaaa 11 100 chennai
aaaa 11 200 chennai
cccc 22 30 coimbatore
dddd 33 45 chennai
dddd 22 100 chennai
dddd 33 200 chennai

my output should be

name pid hours place
aaaa 11 300 chennai
cccc 22 30 coimbatore
dddd 33 245 chennai
dddd 22 100 chennai

can anyone help??

09-16-2011, 01:36 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<script type="text/javascript">
var A=[
var AA=[]
for (var add,z0=0;z0<A.length;z0++){
for (var z0a=0;z0a<AA.length;z0a++){
if (AA[z0a][0]==A[z0][0]&&AA[z0a][1]==A[z0][1]){
if (add){



10-10-2011, 06:52 AM
Thank you..

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum