Skip to content

Instantly share code, notes, and snippets.

@neodigm
Created April 13, 2023 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neodigm/b8bc149d797b03bf73fbc1e1080d9019 to your computer and use it in GitHub Desktop.
Save neodigm/b8bc149d797b03bf73fbc1e1080d9019 to your computer and use it in GitHub Desktop.
const fs = require("fs")
const jSmall = require("./json/rics_updated_product_list_small.json"); //
const jClasses = require("./json/rics_export_classes.json"); //
const jSkus = require("./json/rics_export_skus.json"); //
let aOut = []
let sOut = ""
jSmall.forEach(function( sProd ){
let aItems = sProd.split(",")
console.log( aItems[1] + " | " + aItems[10] )
aItems[10] = getClass( aItems[1] )
aItems.join(",")
aOut.push( aItems )
})
function getClass( _sSku ){
let sRetVal = jSkus.filter(function( sSku ){
let aLine = sSku.split( "," )
return ( aLine[0] == _sSku )
})[0]
if( sRetVal ) return "QQQQQQ" + sRetVal.split( "," )[9]
return "N/A"
}
aOut.forEach(function( sProd ){
sOut = sOut + sProd + "\n"
})
try {
fs.writeFileSync('./csv/nd_products.csv', sOut);
} catch (err) {
console.error(err);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment