question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do you access fields in the returned `Row` generated function?

See original GitHub issue

Documentation Is:

const csv = require('csv-parser')
const fs = require('fs')
const results = [];

fs.createReadStream('data.csv')
  .pipe(csv())
  .on('data', (data) => results.push(data))
  .on('end', () => {
    console.log(results);
    // [
    //   { NAME: 'Daffy Duck', AGE: '24' },
    //   { NAME: 'Bugs Bunny', AGE: '22' }
    // ]
  });
  • Missing
  • Needed
  • Confusing
  • Not Sure?

Please Explain in Detail…

Using the example above, how would you access the NAME column of results[0]? I’ve tried results[0].NAME and results[0]['NAME'] and both are undefined.

Your Proposal for Changes

Add a use case for console.log’ing a property column value

This is what I have tried

> typeof results[0]
'object'
> Object.getOwnPropertyNames(results[0])
[ 'NAME' ]
> results[0]
Row { 'NAME': 'Daffy Duck' }
> results[0].NAME
undefined
> results[0]['NAME']
undefined

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
shellscapecommented, Jul 16, 2019

@mdjaman please don’t reply with “+1,” “me too,” or “same issue” replies. Instead, use the reaction buttons to show support for an issue or other reply.

0reactions
mdjamancommented, Jul 16, 2019

Have the same issue environment node v9.5.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Examples of expressions - Microsoft Support
This article contains examples of expressions in Access to calculate values, validate data, and set a default value for a field or control....
Read more >
1. Retrieving Records - SQL Cookbook [Book] - O'Reilly
The WHERE clause allows you to retrieve only rows you are interested in. If the expression in the WHERE clause is true for...
Read more >
Overview of the SQL ROW_NUMBER function - SQLShack
The ORDER BY clause in the query applied on the SalesOrderID column. We can see that the rows in output are still ordered...
Read more >
How to access a RowDataPacket object - Stack Overflow
function will be used on every row returned by the query const objectifyRawPacket = row => ({...row}); // iterate over all items and...
Read more >
Adding a Complex Calculated Field: IU Only: Files: Access
Calculated fields are created and recomputed each time a query is executed. In the next query, ... To set the function to sum,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found