Last active
August 29, 2015 14:25
-
-
Save benkaiser/038e778552b386206deb to your computer and use it in GitHub Desktop.
Convert CSV with positive and negative lines into one with only positive lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # empty the file | |
| touch positive.csv; | |
| # loop the file | |
| cat mixed.csv | while read line; do | |
| # store the 2nd column minus quotes in the variable X | |
| X=$(echo $line | cut -d ',' -f2 | tr -d '"'); | |
| # if it's greater than 0, put it into the output file | |
| if [[ $X -gt 0 ]] then | |
| echo $line >> positive.csv; | |
| fi; | |
| done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment