JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6922
  • Score
    100M100P100Q117114F
  • License MIT

Infer types from columns in JSON

Package Exports

  • type-analyzer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (type-analyzer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

type-analyzer

Infer types from CSV columns.

Overview

This package provides a single interface for generating the datatype for a given row-column formatted dataset. We support the following datatypes:

  • Geo-JSON,
  • WKT Geometry,
  • Boolean,
  • Currency,
  • Percent,
  • DateTime,
  • Date,
  • Time,
  • Int,
  • Float,
  • Number,
  • Zipcode,
  • City,
  • String

Installation

npm install type-analyzer

Usage

Usage is super simple, simply call computeColMeta on your data like so

var Analyzer = require('type-analyzer').Analyzer;

var colMeta = Analyzer.computeColMeta(data);

But imagine you want to ensure that a column full of ids represented as numbers is identified as a column of strings, type-analyzer's got you. Simply pass an array of rules:

var Analyzer = require('type-analyzer').Analyzer;

var colMeta = Analyzer.computeColMeta(data, [{name: 'id', dataType: 'STRING'}]);
// or
var colMeta = Analyzer.computeColMeta(data, [{regex: /id/, dataType: 'STRING'}]);

Note: Analyzer prefers rules using name over regex since better performance.

And it will short cut around the usual analysis system and give you back the column formatted as you'd expect.

Update

Breaking changes with v1.0.0: Regex has moved into src, but can more easily be accessed from the module.exports from the root. As part of a larger clean up many extraneous util files were removed.