'How can I print a property of an object retrieved from a CSV file?

I read csv file into Javascript and now I want to print only batsman runs and batsman which is batsman name in Console .

I want to print batsman runs, batsman name from objects

const {
  match
} = require("assert")
const csv = require("csv-parser")
const fs = require("fs")
const results = []

fs.createReadStream("deliveries.csv")
  .pipe(csv({}))
  .on("data", (data) => results.push(data))
  .on("end", () => {
    console.log(results)
  })

here is the data which i managed to print out

{
    match_id: '1',
    inning: '1',
    batting_team: 'Sunrisers Hyderabad',
    bowling_team: 'Royal Challengers Bangalore',
    over: '10',
    ball: '2',
    batsman: 'S Dhawan',
    non_striker: 'MC Henriques',
    bowler: 'A Choudhary',
    is_super_over: '0',
    wide_runs: '0',
    bye_runs: '0',
    legbye_runs: '0',
    noball_runs: '0',
    penalty_runs: '0',
    batsman_runs: '1',
    extra_runs: '0',
    total_runs: '1',
    player_dismissed: '',
    dismissal_kind: '',
    fielder: ''
  }


Solution 1:[1]

Instead of consoling the entire results object, use

console.log(results.batsman + " " + results.total_runs);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1