Frosts

pandas-inspired Excel scripting for Office Scripts


Project maintained by JoeyRussoniello Hosted on GitHub Pages — Theme by mattgraham

Reading and Cleaning Data

Frosts provides a simple and flexible API for importing data from a variety of sources — Excel sheets, ranges, JSON, or raw CSV text. These functions return a DataFrame you can immediately work with.

📚 Table of Contents

fr.read_range(range: ExcelScript.Range): DataFrame

Reads a specific Excel range and returns it as a DataFrame.

✅ Use When:

Example:

const sheet = workbook.getActiveWorksheet();
const df = fr.read_range(workbook.getRange("A1:C6"));

fr.read_sheet(Sheet: ExcelScript.Worksheet): DataFrame

Reads the entire used range of a worksheet and returns it as a DataFrame.

✅ Use When:

const sheet = workbook.getActiveWorksheet();
const df = fr.read_sheet(sheet);

Note: This function has the same behavior as running

const sheet = workbook.getActiveWorksheet();
const df = fr.read_range(sheet.getUsedRange());

fr.read_after(Sheet: ExcelScript.Worksheet, n_rows: number, n_cols: number): DataFrame

Reads the used range after skipping a number of rows and columns, returning the remaining area as a DataFrame.

✅ Use When:

const sheet = workbook.getActiveWorksheet();
const df = fr.read_after(sheet, 3, 1); // skips 3 rows and 1 column

Note: This is equivalent to:

const offset = sheet.getUsedRange().getOffsetRange(3, 1).getUsedRange();
const df = fr.read_range(offset);

fr.read_json(json:string):DataFrame

Reads a JSON string and parses it into a DataFrame.

✅ Use When:

read_csv(input_text: string, errors: (“raise” | “coerce”) = “raise”,start_index: number=0, line_separator:string = “\n”): DataFrame

Reads a raw CSV string and returns a DataFrame.

✅ Use When:

Example:

    const csv = "Name,Score\nAlice,88\nBob,90";
    const df = fr.read_csv(csv);

Or skipping the first row:

    const csv = "Report From 4/1/2024\nName,Score\nAlice,88\nBob,90";
    const df = fr.read_csv(csv,"coerce",1);

fr.to_numeric(values:(string|number|boolean)[]):number[]

Converts an array of strings (or mixed values) to numbers. Non-convertible values become NaN.

const raw = ["100", "200.5", "invalid", "", null];
const converted = fr.to_numeric(raw);
console.log(converted);
// Output: [100, 200.5, NaN, NaN, NaN]

Frost’s flexible and intuitive design makes reading and writing data a breeze — whether you’re pulling from Excel sheets, parsing raw CSV, or working with JSON APIs. With just a few lines of code, you can go from messy inputs to clean, structured DataFrames ready for transformation, analysis, and export.

Now that you’ve mastered data input, you’re ready to start processing data in the DataFrame object!

Return to API Reference