Skip to main content

## block

The block command allows you to mark blocks of CSV records depending on values in the first and last records of the blocks, and to remove them, or to remove records not in a block.

See also: eval, find, remove

Flag | Req'd? | Description
-be expr | Yes | Specifies how a block begins using the eval expression language. If the expression evaluates to true, the record is considered to be the start of a block.
-ee expr | Yes | Specifies how a block ends - if the expression evaluates to true, then the record marks the end of the block. If no end record is encountered before end-of-file, the end-of-file is treated as the end record.
-r | No | If this flag is used, then blocks are removed from the output stream.
-k | No | If this flag is used, then blocks are retained in the output stream, and records not in a block are removed.
-m marks | No | Mark blocks. The marks parameter is a two-entry comma-separated list. Blocks are marked with the first entry in the list, and non-blocks with the second. The marker is inserted as the first field in the output stream.
-x | No | Specifies that the begin/end records are not part of a block.

This example marks all the countries in the countries.csv file that belong to the Euro with "EUR"

csvfix block -be '$1 == "FR"' -ee '$1 == "IT"' -m 'EUR,---' data/countries.csv

producing:

"---","GB","United Kingdom"

"EUR","FR","France"

"EUR","DE","Germany"

"EUR","NL","Netherlands"

"EUR","IT","Italy"

"---","US","United States"

Created with the Personal Edition of HelpNDoc: Produce online help for Qt applications

####