Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6351091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:56:09+00:00 2026-05-24T21:56:09+00:00

I’m loading different indicator CSV files into JavaScript, example: CSV for population: id,year,value AF,1800,3280000

  • 0

I’m loading different indicator CSV files into JavaScript, example:

CSV for population:

id,year,value
AF,1800,3280000
AF,1820,3280000
AF,1870,4207000
AG,1800,37000
AG,1851,37000
AG,1861,37000

For each indicator file I need to:

  • Gap fill missing years for each entity (id)
  • Find the time span for each entity
  • Find the min and max for each entity
  • Find the time span for the indicator
  • Find the min and max for the indicator

What is an inexpensive way of performing these operations? Alternatively, is there a good JavaScript library for performing these kind of common data operations and storing the data effectively in various object representations?

I’d like the final representation of the above file to look something like:

data = {
    population : {
        entities : 
            AF : {
                data : {
                    1800 : 3280000,
                    1801 : 3280000,
                 },
                entity_meta : {
                    start : 1800,
                    end : 
                    min : 
                    max :
             },
            [...]
        indicator_meta : {
                start : 1700,
                end : 
                min : 
                max :
        }
        [...]

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:56:10+00:00Added an answer on May 24, 2026 at 9:56 pm

    Lets Assume that you have the CSV data in a 2d array:

    var data = [[AF,1800,3280000],
    [AF,1820,3280000],
    [AF,1870,4207000],
    [AG,1800,37000],
    [AG,1851,37000],
    [AG,1861,37000]]
    

    For this example I will use jQuerys utility functions as it will make the job a lot easier without any real overhead.

    // we will loop thru all the rows
    // if the id does not belong to the entities then we will add the property.
    // if the property does exist then we update the values
    
    var entities = {}
    $.each(data, function (i, n) {
    
        // set property
        if (!entities[n[0]]) {
            entities[n[0]] = {
                data : {
                    n[1]: n[2]
                },
                entity_meta: {
                    start: n[1],
                    end: n[1]
                    min: n[1]
                    max: n[1]
                }
            }
    
        // update property
        } else {
    
            // add new data property
            entities[n[0]]['data'][n[1]] = n[2];
    
            // if the property should change then update it
            if ( entities[n[0]]['entity_meta']['min'] > n[1] ) {
                 entities[n[0]]['entity_meta']['min'] = n[1];
            }
        }
    });
    

    That obviously isn’t all the code but it should explain clearly the approach that should be taken.

    Also not that your intended final object structure is very much over complicated you should really use arrays where appropriate, especially for entities and data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
i got an object with contents of html markup in it, for example: string
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.