Skip to content

Instantly share code, notes, and snippets.

@fonylew
Last active May 15, 2016 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fonylew/070d5b5be49321f8e6f00dfb04376b24 to your computer and use it in GitHub Desktop.
Save fonylew/070d5b5be49321f8e6f00dfb04376b24 to your computer and use it in GitHub Desktop.
LC_ALL=C fgrep -n -f exclude.csv fav_story_test.csv > linenum.txt
comm -23 notlinenumber.txt exclude.csv
#get first column
cut -d : -f 1 linenum.txt > linenumber.txt
cut -d : -f 2 linenum.txt > notlinenumber.txt
//slow
cat linenumber.txt | while read line; do head -n $line random_pred.txt | tail -1; done >> random_diff.txt
//fast
cat linenumber.txt | while read line;
do
sed "${line}q;d" random_pred.txt >> random.txt
done
paste -d ',' user.csv random.txt > random_exclude.csv
cat random_exclude.csv >>concat.csv
sort --field-separator=',' -n concat.csv > sorteduser_output.csv
#remove first column
cut -d , -f 2- sorteduser_output.csv > output.csv
zip -r output output.csv
for i in `seq 0 1088`; do gsutil cp gs://dekd/out/recommend$i/part-00000 - ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment