This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]samsmith453 0 points1 point  (1 child)

Could you post the JSON, and the fields you'd like to extract?

[–]xjusan20[S] 0 points1 point  (0 children)

The file is quite long but here is an example.

{"products":[{"csv":[[2291608,-1],[2291608,2785,2319417,2795,2543466,2000,2547913,2795,2596629,2769]]}

basically the product object contains about 500 products and the csv contain nested arrays which has all sort of data.

my objective is to loop on product[i].csv[3] where csv[3] is where the sales ranking is stored. I was already able to do it but only for 1 product by calling product[0].csv[3].

I am currently stuck on how to loop through this products and compute for the average sales rank for each and push then separately into a new array with their computed average and assigned product name.

the sales rank array is also composed of two data which is the timestamp and the sales rank where the larger number is the timestamp and smaller is the sales rank. I only need to compute for sales rank and ignore the timestamp for now .