concept new csv file in category data

appears as: new CSV file
Data Wrangling with JavaScript

This is an excerpt from Manning's book Data Wrangling with JavaScript.

5.8.5 Outputting a new CSV file

We almost have our result! The final thing we must do is to output the data as a new CSV file. This is made simple with Data-Forge’s asCSV and writeFile functions, as shown in the following listing. If you run this code, it will output a CSV file called trend_output.csv.

Listing 5.12 Computing the Trend column with the help of Data-Forge and outputting a new CSV file (listing-5.12.js)
const dataForge = require('data-forge');
const formulajs = require('formulajs');

dataForge.readFile("./data/monthly_crashes-cut-down.csv")
    .parseCSV()
    .then(dataFrame => {
        dataFrame = dataFrame
            .parseFloats(["Month#", "Year", "Crashes",
                "Fatalities", "Hospitalized"]
            )
            .setIndex("Month#");
        const fatalitiesSeries = dataFrame.getSeries("Fatalities");
        const fatalitiesSeriesWithForecast =
            fatalitiesSeries.rollingWindow(6)
                .select(window => {
                    const fatalitiesValues = window.toArray();
                    const monthNoValues =
                        window.getIndex().toArray();
                    const nextMonthNo =
                        monthNoValues[monthNoValues.length-1] + 1;
                    return [
                        nextMonthNo,
                        formulajs.FORECAST(
                            nextMonthNo,
                            fatalitiesValues,
                            monthNoValues
                        )
                    ];
                })
                .withIndex(pair => pair[0])
                .select(pair => pair[1]);
        const dataFrameWithForecast = dataFrame.withSeries({
            Trend: fatalitiesSeriesWithForecast
        });
        return dataFrameWithForecast
 .asCSV()  #1  
 .writeFile("./output/trend_output.csv");    #2  
    })
    .catch(err => {
        console.error(err && err.stack || err);
    });

#1   Instructs Data-Forge to serialize the data in the CSV format
#2   Writes the CSV data to your output file