Skip to content

Instantly share code, notes, and snippets.

@wings27
Created October 24, 2016 10:29
Show Gist options
  • Save wings27/abb8f6679ddb7b2323cc4dd3f891fc19 to your computer and use it in GitHub Desktop.
Save wings27/abb8f6679ddb7b2323cc4dd3f891fc19 to your computer and use it in GitHub Desktop.
filter lines starting with SHOW and SELECT from a sql file
import sys
def main():
try:
sql_file = sys.argv[1]
with open(sql_file, 'r') as f:
lines = f.readlines()
filtered_lines = filter(lambda l:
not l.startswith('/*')
and not l.startswith('SHOW')
and not l.startswith('SELECT')
, lines)
for line in filtered_lines:
print(line)
except IndexError:
print('file argument is required.')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment