Giter Club home page Giter Club logo

detete's Introduction

DeTeTe

Tool for quick data transforming.

It is pre-configured VS Code workspace with simple API for manipulating files. Any file located in bin directory is executed upon saving for very quick iterating.

Setup

  1. Download ZIP of this repository or fork it and clone.
  2. open _DeTeTe.code-workspace in VS Code (File -> Open Workspace from File...)
  3. VS Code will ask if you trust the authors of the files in this folder, you can anser 'no', review code and disable restricted mode later. If you choose 'yes', VS Code will install 3 extensions (dart, file watcher and vs code runner) and enable running dart files in bin directory when the file is saved.
  4. Run dart pub get in VS Code terminal do download dependencies.

Usage basics

You can write single use scripts in bin/scratchpad.dart. If you wish to keep script for longer, you can duplicate file bin/template.dart and name it appropriately.
Your code goes into transform() method. Three things are required:

  1. Read input(s)
    var content = input.readAsString(filepath: "inputs/input1.txt");
  2. Modify data
    content = content.replaceAll("foo", "bar");
  3. Write output(s)
    output.writeAsString(content, filepath: "outputs/output1.txt");

API supports chain calls to allow writing short code:

input
    .readAsString(filepath: "inputs/input1.txt")
    .replaceAll("foo", "bar")
    .writeAsString(filepath: "outputs/output1.txt");

Complete example and more here: EXAMPLES

Running your script from command line

Your script can be run from command line providing alternative paths for inputs and outputs. For clarity input path and output path lists are separated.
dart run bin/scratchpad.dart -i inputs/arg1.txt inputs/arg2.txt -o outputs/arg1.txt
This will map provided paths to inputs/outputs in script in order of execution. For code:

  var content1 = input.readAsLines(filepath: "inputs/input1.txt");
  content1.sublist(0, 5).writeIterableAsString(filepath: "outputs/output1.txt");
  var content2 = input.readAsLines(filepath: "inputs/input2.txt");
  var outputContent1 = content1 + content2;
  output.writeIterableAsString(outputContent1,
      filepath: "outputs/output2.txt", skipInCliArgs: true);

Mapping will be as follows:

  • inputs/input1.txt will be replaced with inputs/arg1.txt
  • outputs/output1.txt will be replaced with outputs/arg1.txt
  • inputs/input2.txt will be replaced with inputs/arg2.txt
  • outputs/output2.txt will NOT be replaced, because skipInCliArgs parameter is used, which disables assigning new path from command line arguments

NOTE: Counts of paths provided in -i and -o arguments must be equal to inputs/outputs defined in code (minus those with skipInCliArgs set to true). Script will terminate if not enought path are provided. When too much paths are provided script will run normally.

API

API documentation can be found here: API

detete's People

Contributors

coreorb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.