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

data-file-generator

v0.8.26

Published

data-file-generator is all about generating data for testing using a template feed in from excel spreadsheet(s).

Downloads

10

Readme

Data File Generator

To generate multiple copies of a file using a data contained in a spreadsheet with on a template(s)

Getting Started

npm install data-file-generator

Set up

To start, data needs to be added into an excel spreadsheet, then the template file(s) will need to be created and marked up, then the config files need to be created.

file structure:

.
+-- data-files
|   +-- config
|       +-- default.json
|       +-- test-sample.json
|   +-- data
|       +-- template
|           +-- basic-template.xml
|       +-- sample.xlsx
+-- datafile.opt

config folder contains all config json files that determine how the templates and spreadsheet data will be used

data folder contains all the templates and test data spreadsheet to be used in the file generation

data/template contains the marked up templates to be used in the file generation

output (folder will be created) contains all the files generated from the template with the data provided in the spreadsheets

datafile.opt file contains location of where data files exists (including config, templates, output)

Preparation

  1. Mark up template file
    • Identify all values in your template file that you expect data to be replaced
    • Replace each instance in the template with keyword and braces eg. {KEYWORD}
    <SampleRs>
        <UNIQUE_ID>{UNIQUE_ID_COLUMN}</UNIQUE_ID>
        <VALUE1>{SHEET1_COLUMN_VALUE1}</VALUE1>
        <VALUE2>{SHEET1_COLUMN_VALUE2}</VALUE2>
        <EXISTING_VALUE>some value that can be ignored</EXISTING_VALUE>
    </SampleRs>
    • Save template file into ./data/template folder
  2. Setup your spreadsheet, where the first row in your spreadsheet will contain the keyword as a heading
    • Save spreadsheet into ./data folder

| UNIQUE_ID_COLUMN | SHEET1_COLUMN_VALUE1 | SHEET1_COLUMN_VALUE2 | |-----------|:-----------:|-----------:| | ID_000 | AAA | DDD 123 | | ID_001 | BBB | EEE 456 |

  1. Create the config.json

the default.json is used to add in global values that will be shared by other config files, such as the name of the spreadsheet to use (in this case: "inputSheet": "data/sample.xlsx") and also specifies where and what default values for the output folder exist

config files will be merged with the default.json, so any values added to the default.json will be automatically appled to other config files.

config/default.json

{
  "profileName": "default",
  "inputSheet": "data/sample.xlsx",
  "output": {
    "folder": "output/",
    "fileExtension": ".json"
  },
  "useExistingFilenameColumn" : "USE_FILE_NAME",
  "startRow" : 0
}

other config json files added to config folder will apply additional information about what is to be generated, for example the template to be used, filename prefix, unique Id to be applied and file extension

config/test-sample.json

{
  "profileName": "test-sample",
  "sheetName": "Sheet1",
  "startRow": 2,
  "endRow": 500,
  "output": {
    "folder": "output/folder/",
    "fileNamePrefix": "PROFILE-PREFIX",
    "fileIdColumn": "UNIQUE_ID_COLUMN",
    "fileExtension": ".xml"
  },
  "templates": [
    {
      "name": "default",
      "path": "data/template/",
      "fileName": "basic-template.xml"
    }
  ]
}

NOTE: the profileName for each template needs to be unique, as it is this name that will used to determine which template(s) will be used generate test files from

Usage

To generate files run: data-file-gen <profile-name>

or

./node_modules/bin/data-file-gen <profile-name>

to test scripts in repo:

node index.js <profile-name>

where <profile-name> can be a comma delimited list of profiles, eg. test-sample or test-sample1,test-sample2,test-sample3

output files will appear in the output folder

Useful samples

./config/sample/sample.json contains the different combinations and values that can be used for the config json files

./test/ directory contains examples of config files, templates, worsksheets