Useful Unix commands for exploring data
unixdata-explorationcommand-lineawkdata-science
Abstraction: Unix command-line tools for quick data file exploration and transformation
Key points:
head -1to check column names;wc -lto count records;head -N | tail -1to inspect a specific rowuniq -dfinds duplicate records;uniq -uextracts unique records — requires adjacent duplicates (sort first)sort -n -t',' -k3for numerical sort on a specific CSV column;-rfor descending orderawk -F "," '{print NF}'counts columns;NF= number of fields,NR= number of rowsawkcan split files by column value:'{print > $4"_output.csv"}'creates one file per unique valueawkcomputes running aggregates:'{colSum+=$2} END {print colSum/NR}'for column averages
Connections: Data Exploration · Command Line Tools · Unix
Source: http://datavu.blogspot.com/2014/08/useful-unix-commands-for-exploring-data.html