Skip to content

Instantly share code, notes, and snippets.

@rrguntaka
Created November 9, 2011 22:56
Show Gist options
  • Save rrguntaka/1353440 to your computer and use it in GitHub Desktop.
Save rrguntaka/1353440 to your computer and use it in GitHub Desktop.
Parse tab limited, two level text file
require "rubygems"
require "sequel"
DB = Sequel.connect('jdbc:sqlite:store.db') #
all_tables = DB[:sqlite_master]
topics = [];goals = [];prev_ind = 0;second_ind = 0
Dir.glob("*.txt").each do |f|
IO.readlines(f).each do |line|
if line[0..2] == '[ ]'
second_ind+=1
goals.push([second_ind, line[4..-2], prev_ind])
else
prev_ind+=1
topics.push([prev_ind, line[0..-2]])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment