Skip to content

Instantly share code, notes, and snippets.

@oshea00
Last active May 1, 2018 19:27
Show Gist options
  • Save oshea00/03eb8f1249736baae17fbec5aa4e48d1 to your computer and use it in GitHub Desktop.
Save oshea00/03eb8f1249736baae17fbec5aa4e48d1 to your computer and use it in GitHub Desktop.
Filter rows example
import io
f = open('somefile.txt','w')
freq = 2
rows = []
rows.append('row a')
rows.append('row b')
rows.append('row c')
rows.append('row d')
rows.append('row e')
rows.append('row f')
def filter_rows(r,f):
return [row for (i,row) in enumerate(r) if i%f == 0]
f.writelines(["%s\n" % r for r in filter_rows(rows,freq)])
f.flush()
@oshea00
Copy link
Author

oshea00 commented May 1, 2018

Cleaner version of my chicken scratch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment