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 9230639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:52:33+00:00 2026-06-18T05:52:33+00:00

I am developing an online tool to display information in an organized dashboard interface.

  • 0

I am developing an online tool to display information in an organized dashboard interface.
I am pulling the data from a CSV spreadsheet and separating them into another multiD array depending on one field in the overall CSV data array.

This is what I have tried:

        // arr is the array that holds the entire CSV data
        // inds is where I need the entries separated by industry (arr[i][0])
        var indx = 0; // using to add new array to inds array
        for(var i = 1; i < arr.length-1; i++){ 
            if(arr[i][0] === arr[i-1][0]) {
                if(! inds[indx] ) {
                    inds[indx] = []
                } else {
                    inds[indx].push(arr[i]);
                }
            } else {
                indx++;
            }
        }

Basically what this does:
If the industry field is the same as the entry before, throw it into the arr array with the index of indx, otherwise, add one to the indx for the next industry.

The problem with this solution:
It skips the 1st entry of the industry, because the row before was a different industry, so the arr[i-1][0] is checking the last industry and skips the 1st row of the next industry.

How can I reformat this script:
I was thinking maybe nested for/while, but not sure. The way I am thinking of the logic is:
For each row of the csv, while industry column is the same, toss into respective inds[index]. Or, extract rows from arr by the same value of arr[i][0].

I am sure there is an easier solution, and that is why I am here, so I hope I got my thoughts across clearly and I appreciate any and all feedback.

If you need more clarification, just let me know in the comments.

  • 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-06-18T05:52:33+00:00Added an answer on June 18, 2026 at 5:52 am

    Does the following logic work?

    var indx = -1;
     // using to add new array to inds array
            for(var i = 1; i < arr.length-1; i++){ 
                if(arr[i][0] !== arr[i-1][0]) {
                    indx++;
                    inds[indx] = []
                }
                inds[indx].push(arr[i]);
            }
    

    Updated.

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

Sidebar

Related Questions

I am developing one web site using phpfox tool. In dashboard i want to
I am developing an online product using GAE and Python. Certain data in my
I am developing an online tool in .NET 4 to read potentially large (thousands
I am developing online shopping system. Only UK customers can place an order from
I am developing online form that would store values and passed them to another
I'm developing an online tool that involves image editing. Pixlr is my first choice
I'm developing an online pong game in which two players could play between them.
I'm developing online examination system in php-mysql. That exam will consist of multiple-choice questions;
I'm developing an online store with Magento. The site will be high traffic and
I'm developing an online website (using Django and Mysql). I have a Tests table

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.