InfoHeap
Tech tutorials, tips, tools and more
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Linux/Unix Command Line tutorials

  • Awk
  • Curl
  • Edit a file without changing its timestamp on Linux
  • Find which process is listening on a port on Linux
  • Get file size in bytes on Linux
  • How to delete files starting with dash/hyphen
  • How to kill unresponsive ssh session using escape sequence
  • How to show environment variable for a process id (pid)
  • How to sort using a specific field on Linux
  • How to specify environment variable for a command on Linux
  • How to zip/unzip a directory with password
  • ImageMagick
  • Impact on LC_ALL on Linux sort
  • Linux - find listening ports
  • Linux - find top directories by used disk size (excluding size of subdirectories)
  • Linux - how to run a command as different user
  • Linux - list only directories
  • Linux - providing sudo access to a users - some best practices
  • Linux - sending mail from command using mailutils
  • Linux file timestamps
  • Linux how to modify a user using usermod
  • Linux ping a port using netcat
  • Linux replace comma with newline
  • Linux screen - quick start guide
  • Linux what package provides a file
  • Linux/Unix - How to go to previous directory
  • Linux/Unix - find inode number of a file
  • Linux/Unix - truncate a large log file without deleting it
  • Linux/Unix history with date and time
  • Memcache - how to dump all keys and values on command line
  • Mongo - cli quick start guide
  • Perl command line - replace multi line comments
  • Python/Perl/Unix one liners
  • Rsync
  • Ruby gem - handy reference
  • SSH
  • Some handy linux gnu date commands
  • Use watch to monitor a command at some frequency on Linux
  • bower - installation and quick start guide
  • csvkit - parse csv file and data on Linux command line
  • ffmpeg
  • grep without regex (fixed string)
  • redis cli quick start tutorial
  • wget handy commands

Linux find

  • Find recently modified files on Linux
  • Linux - find and delete files older than 30 days
  • Linux - find files containing specific text
  • Linux find - ignore case in name
  • find - exclude directory or file pattern
 
  • Home
  • > Tutorials
  • > Linux

csvkit – parse csv file and data on Linux command line

on Jun 4, 2020

csvkit can be used to extract and process fields from a csv file on Linux or Mac.

  1. Install python3 if not installed already. The command to install python3 on Amazon Linux
    sudo yum install python3
  2. For Mac you can use the following command
    brew install python3
  3. Install csvkit
    pip3 install csvkit
  4. Extract 2nd field
    printf "first,second,third\nfirst2,second2,third2\n" | csvcut -c 2
    second
    second2
  5. Extract 2nd field and use delimiter space
    printf "first second third\nfirst2 second2 third2\n" | csvcut -d " " -c 2
    second
    second2
  6. Extract column by name
    printf "col1name,col2name,col3name\nfirst,second,third\nfirst2,second2,third2\n" | csvcut -c col1name
    col1name
    first
    first2
  7. Sort on first field
    printf "col1name,col2name,col3name\nc,c1,c2\nb,b1,b2\n" | csvsort -c 1
    col1name,col2name,col3name
    b,b1,b2
    c,c1,c2
  8. Grep data where 2nd field field has specific value
    printf "col1name,col2name,col3name\nc,c1,c2\nb,b1,b2\n" | csvgrep -c 2 -r 'b1'
    col1name,col2name,col3name
    b,b1,b2
  9. Ignore header (this will create default header a,b,c,… in output)
    printf "col1name,col2name,col3name\nc,c1,c2\nb,b1,b2\n" | csvgrep -H -c 2 -r 'b1'
    a,b,c
    b,b1,b2


Suggested posts:

  1. Linux – sending mail from command using mailutils
  2. Command line – top IP list from apache access log
  3. How to sort using a specific field on Linux
  4. PHP command line – show errors
  5. Perl command line – replace multi line comments
  6. Find memcache request hit rate on linux command line
  7. Using JSLint on command line on Ubuntu linux – quick start guide
  8. Command line – run python webserver
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Linux/Unix Command Line

Follow InfoHeap

facebook
twitter
googleplus
  • Browse site
  • Article Topics
  • Article archives
  • Recent Articles
  • Contact Us
  • Omoney
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries

Copyright © 2023 InfoHeap.

Powered by WordPress