Skip to content

pspiagicw/sylvie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sylvie

Sylvie is a enchantress of data.It is a replacement of GNU Coreutils for simpler tasks .It is also a single file , portable and syntactically similar to Python.

./sylvie.png

Systems

Sylvie has been devloped and tested on Arch Linux , other GNU/Linux systems are supported with Python 3.9 installed .

Installation

It is uploaded to PyPI , thus can be installed using Pip.

pip install sylvie

Dependencies

It only depends on pygments for colorizing input .

Usage

Sylvie is a command line tool , thus must be controlled with command line arguments. Different arguments control how the data is transformed inside Sylvie.

It does not replace tools like awk , uniq , sed etc . For complex data transformation those tools are the right tools.

Order matters in Sylvie , arguments can be repeated for further transformation , some examples are given , also a youtube video is here.

Sylvie by default takes input from STDIN , which can be given using | operator in POSIX shells(Bash , Zsh).For instead taking input from file use --file argument.

Arguments

ArgumentDescription
–fileUses the given file as input rather than STDIN
–upperTransform current stream into uppercase
–lowerTransform current stream into lowercase
–choiceNarrow data by selecting given range of lines(Takes input as range)
–divertDiverts data stream to given filename , along with continuing data stream.
–countCounts data stream by the given method (Word or line)
–sortSorts data stream by given method(Alphabetical , etc)
–storeStore current data stream into a variable
–searchNarrows data stream to lines containing given search term
–concatConcatenates given variable data to current data stream
–varReplaces current data stream with the one in given variable
–linumAdds line numbers to data straem with given method
–outputOutputs current data stream to given filename , ending current data stream
–uniqueOnly forwards unique lines/word in data stream
–colorTry to colorize output using pygments
–tabularEnter tabular mode

Variables can be stored using --store argument and retreived using --var argument. By default input variable contains original input to Sylvie.

Range in --choice is either

  • Single integer for that specific line
  • start:end format , both must be given if range is used. :end , and start: are invalid
  • start:end:skip format , all three numbers must be given.

Tabular mode

This mode interprets data stream as table containing rows and column , special arguments work in this mode.

For more complex tabular operations on data stream , it is recommended to use awk.

Using tabular mode arguments without tabular mode does nothing to data stream.

Some argument exit tabular mode , which means you have to use --tabular again for more tabular operations.

Tabular Mode Arguments

ArgumentsUsage
–columnSelects a given column no(Starts with 0)
–stripStrip data of given letters (Pos for left strip and neg for right strip)
–maxGives maximum of given column and exits tabular mode
–minGives minimum of given column and exits tabular mode
–meanGivesn mean of given column and exits tabular mode
–medianGivesn median of given column and exits tabular mode
–stdGives standard deviation of given columna and exits tabular mode
–addSums given column and exits tabular mode
–multiplyMultiply given column with a number or value of variable
–divideDivide given column with a number or value of variable
–varianceGives variance of given column and exits tabular mode

Any arguments can be repeated except --file which takes in input only once., in any order, Sylvie outputs to STDOUT , thus can again be piped to some other tool or itself.

Examples

These examples are just an slice of what sylvie can do , for more thourough explanation refer to this youtube vide.

Using it to calculate average temperature of my cores.This uses lm-sensors package , which gives temperature info in Linux systems.

lm-sensors provides sensors command for finding temperature.

sensors | sylvie.py --search Core --tabular --column 2 --strip 1 --strip -3 --mean

This uses the /proc/meminfo file in Linux for calculating percentage of free memory(RAM).

sylvie.py --file /proc/meminfo --search MemTotal --tabular --column 1 --store total --var input --search MemFree --tabular --column 1 --divide total

Sylvie can colorize source code and add line numbers. This example adds color , line number and displays first ten lines of Sylvie's own source code

sylvie.py --file sylvie.py --color --linum arabic --choice 0:10

About

Sylvie the enchatress of data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors