Skip to content

A Front End for xsv - A fast CSV command line toolkit

License

Notifications You must be signed in to change notification settings

emacsbliss/xsv.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

xsv.el

xsv.el is a front end for CSV toolkit xsv. xsv provides very powerful ways to work with CSV file and xsv.el brings that awesomeness into Emacs.

installation

For now, either clone the repo and add to load-path or use package manager like straight.

Why

Emacs has CSV mode to work with CSV files, it has nice things but I find it lacking certain functionality I want and I have to resort to Numbers/Excel from time to time.

After I discovered the xsv, I realize it could bridge the gap I encountered before.

Some examples are:

  • I want to filter the csv file to show only rows where certain columns match my criteria
  • I want to only view columns I’m interested

xsv provides much more functionalities than I need, but I think I will bring in more and more into the package to make it even more useful.

filter the rows in CSV file

Once package is loaded, run M-x xsv/filter on a buffer visiting csv file or buffer contain valid csv format content and it will ask for the input to be used for filtering.

The input can contain multiple criteria and each criteria should be in one of these following syntax:

  • columnA = ‘regexA’
  • columnB != ‘regexB’

First one means search columnA where its value match regexA. Second form means search columnB where its value NOT match regexB.

In the case where column name contains spaces, you need to single quote it:

'transaction type' = 'debit'

You will always need to single quote the value.

Criteria can be joined by using & like this:

columnA = 'regexA' & columnB = 'regexB' & columnC != 'regexC'

It means return rows where columnA matches regexA AND columnB matches regexB AND columnC NOT matches regexC.

The filtered result will be presented in a different buffer with prefix xsv- so the original buffer/file are left untouched.

select certain columns in CSV file

Run M-x xsv/select then enter the columns interested. Note you need to single quote the column name if there is space in it. Also column names should be separated by , and there is NO space around the separator. The column name is case sensitive.

For eg, this works:

Date,'Transaction Type'

This will NOT work (due to extra space after ,):

Date, 'Transaction Type'

About

A Front End for xsv - A fast CSV command line toolkit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published