How do you access fields in the returned `Row` generated function?
See original GitHub issueDocumentation 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:
- Created 5 years ago
- Comments:7
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
Have the same issue environment node v9.5.0