xsv slice -s 2 -e 4 data.csv

Category: Data Science & Analysis

xsv slice -s 2 -e 4 data.csv

Print rows 2 through 3 of the CSV

The slice command extracts a contiguous range of rows by 0-based index: -s 2 starts at the third row and -e 4 stops before the fifth, so rows 2 and 3 are printed. This is the CSV-aware replacement for sed -n on tabular data. Without -e the slice runs to the end of the file. Negative indices count from the end.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.