Options
All
  • Public
  • Public/Protected
  • All
Menu

Data-Forge FS

Index

Functions

asCSV

  • asCSV<IndexT, ValueT>(this: IDataFrame<IndexT, ValueT>, options?: ICSVOutputOptions): ICsvSerializer
  • Treat the dataframe as CSV data for purposes of serialization. This is the first step you need in serializing a dataframe to a CSV data file.

    example
    
    df.asCSV().writeFileSync("my-data-file.csv");
    
    example
    
    await df.asCSV().writeFile("my-data-file.csv");
    
    example
    
    const options = { ... };
    await df.asCSV(options).writeFile("my-data-file.csv");
    

    Type parameters

    • IndexT

    • ValueT

    Parameters

    Returns ICsvSerializer

    Returns a ICsvSerializer that represents the dataframe for serialization in the CSV format. Call writeFile or writeFileSync to output the CSV data to a text file.

asJSON

  • asJSON<IndexT, ValueT>(this: IDataFrame<IndexT, ValueT>): IJsonSerializer
  • Treat the dataframe as JSON data for purposes of serialization. This is the first step you need in serializing a dataframe to a JSON data file.

    example
    
    df.asJSON().writeFileSync("my-data-file.json");
    
    example
    
    await df.asJSON().writeFile("my-data-file.json");
    

    Type parameters

    • IndexT

    • ValueT

    Parameters

    • this: IDataFrame<IndexT, ValueT>

    Returns IJsonSerializer

    Returns a IJsonSerializer that represents the dataframe for serialization in the JSON format. Call writeFile or writeFileSync to output the JSON data to a text file.

readFile

  • Read a file asynchronously from the file system. Works in Nodejs, doesn't work in the browser.

    example
    
    const df = await dataForge.readFile("my-data-file.csv").parseCSV();
    
    example
    
    const options = {
         // ...
    };
    const df = await dataForge.readFile("my-data-file.csv").parseCSV(options);
    
    example
    
    const df = await dataForge.readFile("my-data-file.json").parseJSON();
    

    Parameters

    • filePath: string

      The path to the file to read.

    Returns IAsyncFileReader

    Returns an object that represents the file. Use parseCSV or parseJSON to deserialize to a DataFrame.

readFileSync

  • Read a file synchronously from the file system. Works in Nodejs, doesn't work in the browser.

    memberof

    Data-Forge

    example
    
    const df = dataForge.readFileSync("my-data-file.csv").parseCSV();
    
    example
    
    const options = {
         // ...
    };
    const df = dataForge.readFileSync("my-data-file.csv").parseCSV(options);
    
    example
    
    const df = dataForge.readFileSync("my-data-file.json").parseJSON();
    

    Parameters

    • filePath: string

      The path to the file to read.

    Returns ISyncFileReader

    Returns an object that represents the file. Use parseCSV or parseJSON to deserialize to a DataFrame.

Generated using TypeDoc