1.0.0 • Published 3 years ago
workstream-to-standup-notes v1.0.0
workstream-to-standup-notes
This code reads a directory containing CSV files and extracts data from them. It then filters the extracted data based on certain criteria, and uses it to create a new set of notes. Finally, it saves the notes as a new CSV file.
Here is a more detailed explanation of the steps taken:
- The code reads the files in the directory specified by the
PROJECTS_LOGS_PATHconstant using thefs.readdirSync()function. - It filters the files based on whether they have a
.csvextension using thefiles.filter()method, and stores the resulting array in thecsvFilesvariable. - The code then creates an empty array called
abc. - It loops through each file in the
csvFilesarray using thecsvFiles.forEach()method. - For each file, the code reads the file using the
fs.readFileSync()method and extracts the data as a string. - It then parses the string as CSV data using the
parse()method from thecsv-parselibrary, with the optionscolumns: trueandskip_empty_lines: true. - It filters the resulting array of records based on whether they contain a certain value for the "Team" field. The specific value(s) to be filtered is determined by the
TEAMSconstant. - For each record in the filtered array, the code extracts relevant data and creates a new object representing a note.
- It then adds the note object to the
abcarray. - If an error occurs while reading or parsing a file, the error message is logged to the console.
- After all the files have been processed, the code checks whether the
abcarray is not empty. - If the
abcarray is not empty, it converts the array to a CSV string using thejson2csv.parse()method from thejson2csvlibrary. - It then writes the CSV string to a new file specified by the
STANDUP_NOTES_PATHandSTANDUP_NOTES_FILEconstants using thefs.writeFile()method. - If an error occurs while writing the file, the error message is logged to the console.
- If the file is successfully written, the message "Saved!" is logged to the console.
1.0.0
3 years ago