FSharp.Data Documentation

repository·main·Indexed 21 days ago

https://github.com/fsprojects/fsharp.data

A library providing F# Type Providers and parsing utilities for strongly-typed or dynamic access to structured data formats including CSV, JSON, XML, and HTML. Includes Type Providers such as CsvProvider, HtmlProvider, JsonProvider, and XmlProvider, as well as HTTP utilities and dynamic parsers like CsvFile and JsonValue.

Tokens
463
Snippets
0
Records
4
Agent score
25%

What's inside FSharp.Data

  1. Overview of FSharp.Data capabilities

    main

    FSharp.Data is a library designed to simplify data access in F# applications and scripts. It provides two primary ways to interact with structured data:

    1. Type Providers: These infer types from a sample document (CSV, HTML, JSON, or XML) to provide type-safe, structured access to documents following that same schema.
    2. Data Access Tools: These provide dynamic, non-type-provider alternatives for parsing data and performing web operations.

    Key features include:

    • Type Providers for CSV, HTML, JSON, XML, and the WorldBank API.
    • HTTP Utilities for sending web requests.
    • Parsers for CSV, HTML, and JSON that offer a simple dynamic API without requiring a schema-based type provider.
  2. Use FSharp.Data Type Providers for type-safe data access

    main

    Type providers allow you to work with structured data formats by inferring types from a sample document. This provides type-safe access to data that follows the same structure as your sample.

    Available Type Providers:

    • CsvProvider<..>: For structured CSV files.
    • HtmlProvider<...>: For HTML documents.
    • JsonProvider<..>: For JSON data.
    • XmlProvider<..>: For XML documents.
    • WorldBank: For accessing data from the WorldBank API.

    To use a type provider, you typically provide a sample URL or a local file path to the provider constructor to define the schema.

  3. Use Data Access Tools for dynamic parsing and HTTP requests

    main

    If you do not want to use a type provider (which requires a known schema), you can use the library's dynamic parsing tools and HTTP utilities:

    • HTTP Utilities: Use the Http type to send HTTP web requests.
    • CSV Parser: Use CsvFile for parsing CSV files without a type provider.
    • HTML Parser: Use the HTML parser for dynamic HTML traversal.
    • JSON Parser: Use JsonValue for parsing JSON data with a simple dynamic API.