0

Having spent hours on Google and SO, I have finally cracked.

I have a PSQL table of outbound flight data of one day sorted by time and destination continent. I am going through all rows of my table, pushing the destination continent of each flight into arrays, with each array representing 15mins of flight data. for example, 1st array - 00:00 to 00:15 would be: [] ......(no flights) 21st array - 05:00 to 05:15 would be: ["NA", "NA", "NA", "EU", "AS", "EU"] etc.

all the way to 96 arrays (96 x 15 mins in 24 hours.)

I have this data pushed into a CSV file with the header being just flights however, when I try to recall the data in d3 using:

d3.csv("/my_file.csv", function(data) {
console.log(data);
})

the object returned is 96 rows of "["NA"" or something equivalent; very obviously it is breaking at the very first comma. Is there a way to retrieve arrays from a CSV file using d3??

1
  • A similar question came up on google groups here which might help (if you haven't already seen it). Commented Oct 17, 2013 at 5:34

1 Answer 1

1

CSV files work best when there is a fixed number of columns in each row. For your data, can you use a JSON file instead? There are different ways you could represent your data as JSON, for example, you could use an object with each property being an array:

{
    "00:00 to 00:15": [],
    "05:00 to 05:15": ["NA", "NA", "NA", "EU", "AS", "EU"]
}
Sign up to request clarification or add additional context in comments.

1 Comment

You are absolutely right. I exported to JSON format and it worked like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.