07-24-2023, 12:54 AM
I have a csv file with stats of players of our gameserver.
I want to build a leaderboard and want to only show their name and score but the csv also includes a lot more of keys.
Here´s an example:
{
id: '2',
steam: 'STEAM_1:1:31692173',
name: 'xyCe',
lastip: 'yeet',
score: '1004',
kills: '3',
deaths: '3',
assists: '0',
suicides: '0',
tk: '0',
shots: '231',
hits: '3',
headshots: '2',
connected: '282',
rounds_tr: '2',
rounds_ct: '0',
lastconnect: '1604265854',
knife: '0',
glock: '0',
hkp2000: '0',
usp_silencer: '0',
p250: '0',
deagle: '0',
elite: '0',
fiveseven: '0',
tec9: '0',
cz75a: '0',
revolver: '0',
nova: '0',
xm1014: '0',
mag7: '0',
sawedoff: '0',
bizon: '0',
mac10: '0',
mp9: '0',
mp7: '0',
ump45: '0',
p90: '0',
galilar: '0',
ak47: '3',
scar20: '0',
famas: '0',
and so on }
So how would I need to update this script to only show the name + score :
```
const csv = require('csv-parser');
const fs = require('fs');
fs.createReadStream('./FFA/csv/rankme.csv')
.pipe(csv({ delimiter: ',', from_line: 2 }))
.on('data', (row) =>
{
console.log(row);
});
```
I want to build a leaderboard and want to only show their name and score but the csv also includes a lot more of keys.
Here´s an example:
{
id: '2',
steam: 'STEAM_1:1:31692173',
name: 'xyCe',
lastip: 'yeet',
score: '1004',
kills: '3',
deaths: '3',
assists: '0',
suicides: '0',
tk: '0',
shots: '231',
hits: '3',
headshots: '2',
connected: '282',
rounds_tr: '2',
rounds_ct: '0',
lastconnect: '1604265854',
knife: '0',
glock: '0',
hkp2000: '0',
usp_silencer: '0',
p250: '0',
deagle: '0',
elite: '0',
fiveseven: '0',
tec9: '0',
cz75a: '0',
revolver: '0',
nova: '0',
xm1014: '0',
mag7: '0',
sawedoff: '0',
bizon: '0',
mac10: '0',
mp9: '0',
mp7: '0',
ump45: '0',
p90: '0',
galilar: '0',
ak47: '3',
scar20: '0',
famas: '0',
and so on }
So how would I need to update this script to only show the name + score :
```
const csv = require('csv-parser');
const fs = require('fs');
fs.createReadStream('./FFA/csv/rankme.csv')
.pipe(csv({ delimiter: ',', from_line: 2 }))
.on('data', (row) =>
{
console.log(row);
});
```