Giter VIP home page Giter VIP logo

csv-filter-splitter's Introduction

csv-filter-splitter

A Bash script tool for filtering and splitting CSV file. This tool is to help you split a large CSV into several CSV files based on filtered criteria(s).

Introduction

I faced a situation recently in my work where i need to split up a csv file into several csv files, based on several criterias. And I needed each file to be name after last criteria specified.

Usage

./dataSplitter <source-csv> <filters-csv> [-d]

This will split the <source-csv>, making sure that every output matched all criteria(s) in <filters-csv>.

The only option is -d, which allows you to get the details of running process instead of plain progress bar.

CSV Structure

Source CSV

"title 1","title 2","title 3","title 4","title 5"
"data r1c1","data r1c2","data r1c3","data r1c4","data r1c5"
"data r2c1","data r2c2","data r2c3","data r2c4","data r2c5"
"data r3c1","data r3c2","data r3c3","data r3c4","data r3c5"

Line 1 must be the title or column name.

Line 2 and below is the raw data.

You need to make sure the last line is an empty line.

Filters CSV

$2,$4,$5
"filter 1", "filter 2", "filter 3"
"filter 1", "filter 2", "filter 3"
"filter 1", "filter 2", "filter 3"

Line 1 must be the column number of filters to be applied based on source-csv, starting with $

Line 2 and below is the filter values.

You need to make sure the last line is an empty line.

Currently you can use up to 5 filters.

Output

The <source-csv> will be splitting into several CSVs in output folder. You will be prompt the output folder name during the execution of the script.

Naming conversion for the files is {second_last_filter_value}_{last_filter_value}.csv. And the folder structure also will follow the filter values.

output/filter_1/filter_2/filter2_filter_3.csv

Buy Me a Coffee

paypal.me/mohdrafhan

csv-filter-splitter's People

Contributors

nullifye avatar

Stargazers

 avatar

Watchers

 avatar  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.