Skip to content

A way to handle nested objects #661

Answered by nshiab
graemebruce asked this question in Q&A
Discussion options

You must be logged in to vote

You can access the values in nested objects by casting them to JSON.

Create a new folder and run npx simple-data-analysis, copy-paste the code below into your index.js or index.ts, then run npm run sda and you should see a new column classification at the end of the table.

The casting to JSON happens on line 24.

import { SimpleDB } from "simple-data-analysis";
import { prettyDuration } from "journalism";

const start = Date.now();

// We set a maximum width to the string columns to keep it readable.
const sdb = new SimpleDB({ nbCharactersToLog: 50 });

const table = sdb.newTable();

// We cache so we don't fetch everytime while working on the file.
await table.cache(async () => {
  await t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by graemebruce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #658 on August 08, 2024 13:17.