npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

etlbot

v1.1.0

Published

A Node JS command line tool to perform transformations on delimited value flat files.

Downloads

3

Readme

etlbot

A Node JS command line tool to perform transformations on delimited value flat files.

Installation

$ npm install -g etlbot

Basic Usage

config

Create an instance of a configuration file from the built in template.

$ etlbot config [destination]

Parameters

| Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | destination | true | ./mystuffFolder | Path to destination folder to which an instance of the templated configuration file will be created. |

transform

Transform delimited flat files from specified source using configuration file.

$ etlbot transform <source> [destination] --config=[path]

Parameters

| Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | source | false | ../listOfStuff.csv | Path to source file to parse from. | | destination | true | ./mystuffFolder | Path to destination folder to which the transformed file will be placed. Note that if you do not provide a destination path the current working directory will be used. |

Options | Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | -c, --config | true | --config=../pathToConfig/etlbot_config.js | Optional path to configuration file defining the transformation. Note if a configuration file path is not provided etlbot will look in the current working directory for etlbot_config.js. |

cache

Build a cache of key value pairs based on a delimited file to be used in subsequent ETL steps.

$ etlbot cache <source> [destination] --config=[path]

Parameters

| Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | source | false | ../listOfStuff.csv | Path to source file to parse from. | | destination | true | ./mystuffFolder | Path to cache destination folder to which on disk cache is placed. This is because with large datasets, purely in memory cache could cause you to run out of memory. Note that if you do not provide a destination path the current working directory will be used to create a cache directory at __etlbotcache. |

Options | Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | -c, --config | true | --config=../pathToConfig/etlbot_config.js | Optional path to configuration file defining the transformation. Note if a configuration file path is not provided etlbot will look in the current working directory for etlbot_config.js. |

filter

Filter a specified delimited flat using a configuration file into a subset of the source file.

$ etlbot filter <source> [destination] --config=[path] --cache=[path]

Parameters

| Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | source | false | ../listOfStuff.csv | Path to source file to parse from. | | destination | true | ./mystuffFolder | Path to destination folder to which the filtered file will be placed. Note that if you do not provide a destination path the current working directory will be used. |

Options | Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | -c, --config | true | --config=../pathToConfig/etlbot_config.js | Optional path to configuration file defining the transformation. Note if a configuration file path is not provided etlbot will look in the current working directory for etlbot_config.js. | | -m, --cache | true | --cache=../pathToCache | Optional path to cache folder. Note if a cache path is not provided etlbot will look in the current working directory for __etlbotcache. |

Configuration File Example

The configuration file is split into two main sections: the parse object defines details required to parse the source file, whereas the destination object defines the required transformations.

var DefaultConfig = {
  parse: {
    delimiter: ',',
    maxRows: null
  },
  transform: {
    delimiter: ',',
    fieldMap: [
      // Note that order of fieldKeys is relevant
      {
        key: 'newKeyName',
        value: function(rowObj){
          return // transformation
        }
      },{
        key: 'anotherKeyName',
        value: 10,
        static: true
      },{
        key: 'oneMoreKeyName',
        value: 'sourceKeyName'
      }
    ]
  },
  cache: {
    {
      key: 'oldCacheKeyReference',
      value: function(rowObj, cache){
        return // value to cache
      }
    },{
      key: 'cacheKey',
      staticKey: true,
      value: function(rowObj, cache){
        return // value to cache
      }
    },{
      key: function(rowObj, cache){
        return //cache key
      },
      value: function(rowObj, cache){
        return // value to cache
      }
    },{
      key: 'oneMoreCacheKeyName',
      value: 'originalKeyName'
    }
  },
  filter: function(rowObj, cache){
    return // is row valid?
  }
};

module.exports = DefaultConfig;

| Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | parse.delimiter | true | ',' | Delimiter in source file by which to parse. | | parse.maxRows | true | 100 | Number of rows to parse. If no value is provided then the whole source file will be parsed. | | transform.delimiter | true | ',' | Delimiter in destination file by which to write with. | | transform.fieldMap | false | [...] | An array of field definitions to transform to. |

Field Definition

| Name | Optional | Example | Description | | ---- | -------- | ------- | ----------- | | key | false | newKeyName | Key name for destination file column header. | | value | false | sourceKeyName, 100, function(rowObj){...} | If the value is a String without the static flag to be true then it is considered the key name of the column header in the source file and thus the value will be mapped accordingly. If the value is a function then each row object from the source file will be passed through this function for the purposes of populating the value for the destination key specified. If the static flag is set to true then the value will be taken as is. | | static | true | true | Flag to indicate that the value provided should be taken as is and placed as the column row value. |