Created
June 15, 2021 18:32
-
-
Save kavioshanaiesecer/5f3563c57a0ffc80158d77aa07289c84 to your computer and use it in GitHub Desktop.
Function to Update the Test Results
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
function updateCSVFile(testResults) { | |
//Read the Provided CSV File | |
fs.readFile('./DATA_CSV_FILE_NAME.csv', 'utf-8', (error, data) => { | |
if (error) { | |
throw error; | |
} | |
const jsonData = Papa.parse(data, { header: true }); | |
//console.log(jsonData); | |
//Iterate Each Request | |
jsonData.data.map((item, index) => item.testResult = testResults[index]); | |
//Updating the JSON Data with Test Results | |
const updatedCSV = Papa.unparse(jsonData.data); | |
console.log(updateCSVFile); | |
//Write to File | |
fs.writeFile('./TestResults/UPDATED_CSV_FILE_NAME.csv', updatedCSV, (error) => { | |
if (error) { | |
throw error; | |
} | |
console.log('Updated Successfully!!'); | |
}) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment