Skip to content

Instantly share code, notes, and snippets.

@benkaiser
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save benkaiser/038e778552b386206deb to your computer and use it in GitHub Desktop.

Select an option

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
# 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