Skip to content

Instantly share code, notes, and snippets.

Created February 25, 2020 12:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Code snippet to fetch column names between select and from keyword to analyse.
def analyse file_path
file =, "r")
counter = 0 # counter for having a 2D Array
writefile = false
array =
file.readlines.each do |line|
if line.start_with? "SELECT"
writefile = true;
array[counter] =
if line.start_with? "FROM"
writefile = false;
counter = counter + 1
array[counter].push line.strip if writefile == true
require 'csv''.\working_output_analysis.csv', 'w+') do |csv|
array.each { |ar| csv << ar }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment