Coder Social home page Coder Social logo

jasper-zanjani / awk-list Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 19 KB

:penguin: Utility written in awk to display tabular content in a manner similar to PowerShell's Format-List.

Shell 14.20% Awk 32.82% Python 52.98%
awk awk-script awk-programming-language awk-language bash bash-script linux csv csv-parser

awk-list's Introduction

CSVreader

These are a couple of scripts I put together that will aid working with .csv files by printing the heading alongside each field's data. The script obviously presumes the first row of the .csv file contains the heading.

It started out as a demonstration .awk script with a .sh wrapper, but I ported it to Python as well.

Usage

CSVreader accepts one (optional) positional parameter: a search string.

Example 1: Invocation without parameters

Here is an example .csv file containing information about some ancient Greek philosophers:

name,city,dob
Socrates,Athens,470 BC
Plato,Athens,428 BC
Aristotle,Stagira,384 BC
Euclid,Alexandria,325 BC
Pythagoras,Samos,570 BC

$ csv greeks.csv

Output:

name      : Socrates 
city      : Athens 
dob       : 470 BC 

name      : Plato 
city      : Athens 
dob       : 428 BC 

name      : Aristotle 
city      : Stagira 
dob       : 384 BC 

name      : Euclid 
city      : Alexandria 
dob       : 325 BC 

name      : Pythagoras 
city      : Samos 
dob       : 570 BC 

Example 2: Search for string

Here is an example csv file containing information about various historical warships:

name,country,displacement,length,beam,commissioned
Yamato,Japan,65027,256,38.9,16 December 1941
USS Enterprise,United States of America,19800,251.4,33.4,12 May 1938
Bismarck,Germany,41700,251,36,24 August 1940
HMS Dreadnought,United Kingdom,18120,160.6,25,2 December 1906
USS Iowa,United States of America,46000,270.43,32.97,22 February 1943
HMS Vanguard,United Kingdom,45200,248.2,32.9,12 May 1946

$ csv USS ships.csv

Output:

name      : USS Enterprise 
country   : United States of America 
displacement: 19800 
length    : 251.4 
beam      : 33.4 
commissioned: 12 May 1938 

name      : USS Iowa 
country   : United States of America 
displacement: 46000 
length    : 270.43 
beam      : 32.97 
commissioned: 22 February 1943 

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.