GithubHelp home page GithubHelp logo

stephan-rayner / csvmaster Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spiffytech/csvmaster

0.0 2.0 0.0 192 KB

It's like `cut`, except it plays nicely when your field separator appears inside your values. Can handle quoted, RFC 4180-compliant CSV files.

License: Other

Go 100.00%

csvmaster's Introduction

Introduction

csvmaster is a tool for working with CSV files on the command line. Why would you want that when you have cut and awk? Because cut and awk don't have any idea what to do with quoted fields. Because sed and awk can't distinguish between a field separator char that actually separates fields, and one that's inside a field's value. Because if you change the delimeter with those tools, they don't know how to quote fields containing the new delimiter.

csvmaster fixes all of that by using an actual CSV parsing engine for reading, writing, and field splitting.

Usage

To print out select fields: csvm --fields=0,1,2 test.csv

To print them out with a different separator: csvm --fields=0,1,2 --out='\t' test.csv

To use an input separator that is not a comma csvm --file=test.csv --in='\t' --out=','

Perhaps you want to actually use sed/awk to parse your data. This command will let you correctly separate your fields, then write out an unquoted CSV with a separator you can more safely parse with stardard command-line tools. cat test.csv | csvm --out='|' --no-rfc

Some lines may be commented out. You may ignore these lines: cat test.csv | csvm --out='|' --comment-char='#'

Short flags

csvm also accepts short flags:

  • -f = filename
  • -F = field numbers
  • -i = input separator
  • -o = output separator

Download

v1.1 for:

Building

Install Go

go build -o csvm csvmaster.go

csvmaster's People

Watchers

James Cloos avatar Stephan Rayner 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.