Created
April 13, 2023 20:23
-
-
Save neodigm/b8bc149d797b03bf73fbc1e1080d9019 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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