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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:21:51+00:00 2026-06-13T08:21:51+00:00

I need to import 8-10 CSV files into some JS code. Each file has

  • 0

I need to import 8-10 CSV files into some JS code. Each file has about 8 different columns. I would like to store this information in an object (possibly identifying the object based on one of the ID fields). The problem is, the easiest way I can think of looks like this:

var authorArr = [];
d3.csv("data/authors.csv", function(csv) {
    csv.forEach(function(d) {
    authorArr[d.record_id] = [];
    d.record_id = +d.record_id;
    d.name = d.name
    d.name_inverted = d.name_inverted;
    d.role = d.role;
    d.sequence = +d.sequence;
    d.is_person = d.is_person;

    authorArr[d.record_id] = d.name;
    authorArr[d.record_id] = d.role;
    etc...

Surely this cannot be the quickest way…Also, there are quite a bit of duplicated record_id values as well, so every time there is a repeat, I would lose all previous data with my horrible approach.

I’m not sure if that’s enough detail. If not, I would be glad to add more.

  • 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-13T08:21:52+00:00Added an answer on June 13, 2026 at 8:21 am

    You can use a temporary variable for the new/current record. Your example also looks like you do not want an array (with gaps) but a map. Here is how I would load the data:

    var authorMap = {}
    
    var loadCSV = function(file){
        d3.csv(file, function(error, data) {
            data.forEach(function(d) {
                var a = authorMap[d.record_id] = {}
                a.record_id = d.record_id
                a.name      = d.name
                a.role      = d.role
            });
        });
    }
    
    loadCSV("file1.csv")
    loadCSV("file2.csv")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some large csv files that I need to import into IEnumerable (prob
I have about 28 csv files and I need to import this into database
I need to to import some csv files into excel 2010 and create a
I need to import some ANSI C code into a project I'm working on.
I need to import a csv file into Firebird and I've spent a couple
In our project we need to import the csv file to postgres. There are
I need to import some Excel spreadsheets into Java objects. I will use POI
i need to import a mysql file into my access db. how do i
I need to import the .sql file of PHP myadmin into SQL Server 2008.
I'm trying to read some values into an array in an .each do code

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.