Skip to content

Commit

Permalink
fix: escape commas in alias
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakia committed Mar 25, 2024
1 parent acbab80 commit 052bfc6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data/nano-reps.csv
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ ranita | NanoHispano,nano_1hispanocq7ow8azrs3mirsccebuh5e3pfk8pkfzfafbyooezpsnwi
Redeemfor.me 🛍️🛒 — Luckynano.com 🎰💰,nano_1oenixj4qtpfcembga9kqwggkb87wooicfy5df8nhdywrjrrqxk7or4gz15b,emulord,Emul0rd,null,null,null,Emulord
repnode.org,nano_3rpixaxmgdws7nk7sx6owp8d8becj9ei5nef6qiwokgycsy9ufytjwgj6eg9,null,null,null,null,null,null
RsNano.com - Nano Rust Port,nano_1tk8h3yzkibbsti8upkfa69wqafz6mzfzgu8bu5edaay9k7hidqdunpr4tb6,gschauwecker,SeniorTawny,gschauwecker,rsnano.com,null,null
ScandiNode 🌐 Green, fast & capable! ,nano_318uu1tsbios3kp4dts5b6zy1y49uyb88jajfjyxwmozht8unaxeb43keork,kevorkc,kevorkdk,null,null,null,null
"ScandiNode 🌐 Green, fast & capable! ",nano_318uu1tsbios3kp4dts5b6zy1y49uyb88jajfjyxwmozht8unaxeb43keork,kevorkc,kevorkdk,null,null,null,null
scoin.cool,nano_3o5oeefdnrha7x7styp1tnmefen7fnrooy4jgnfb1otws54yf7uqfuxmojoy,null,null,null,null,null,AviGopal
SendNudes 👀,nano_3sendnudez9x8zkaid5k17g474f9dc4fuopggzojwop9sbc5isgwah5gbx9n,user_8804 - Gab Parrot#8804,user_8804,Gab_Parrot,null,null,gabparrot
SomeNano.com,nano_1buid1zd65fynxnsmzyjgt1yd84cjrf81xa1mn861wtxmer5ss74bd8kbe4a,pwlk.,somenano.com
Expand Down
20 changes: 19 additions & 1 deletion scripts/generate-nano-reps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ const generate_nano_reps = async () => {
)
// Read the downloaded CSV data
const csv_reps = await read_csv(csv_download_path, {
mapValues: ({ header, index, value }) => (value === '' ? null : value)
mapValues: ({ header, index, value }) => {
if (value === '') {
return null
}

if (header === 'alias') {
return value.replace(/"/g, '')
}

return value
}
})

// Fetch representatives data from the database
Expand Down Expand Up @@ -157,6 +167,14 @@ const generate_nano_reps = async () => {
return alias_a.localeCompare(alias_b)
})

// escape any commas in alias
for (const rep of results) {
// check if alias contains a comma
if (rep.alias.includes(',')) {
rep.alias = `"${rep.alias}"`
}
}

// Convert results to CSV and save
const csv_headers = {}
for (const field of Object.keys(results[0])) {
Expand Down

0 comments on commit 052bfc6

Please sign in to comment.