Skip to content

Instantly share code, notes, and snippets.

require 'csv'
i = 0
CSV.open("./data.csv", headers:true) do |csv|
rows = csv.each
#csv is of type CSV
#"c" is an array of each "a" that causes the block to return true
selected_rows = rows.select do |row|
#"a" is of type CSV::ROW
i = i + 1
def lawyer?(line_to_check)
#some code to check if line is a lawyer
end
def doctor?(line_to_check)
#some code to check if line is a doctor
end
def deGlobDir(matchPattern,path)
Dir.chdir path
e = Dir.pwd
Dir.glob(matchPattern) do |folder|
e = folder
puts e
end
return e
end
require 'tk'
require 'tkextlib/tile'
def lawyer?(line_to_check)
return true if /(?:law(?:\W|\z))|(?:legal)|(?:attorn)|(?:\WP\.*a\W?[^a-z1-9\t])/i =~ line_to_check
end
def on_remove_list?(line_to_check)
return true if /(?:(?:Northwest|United\sStates|TK|Community)\s)?(?:(?:NRAI|CT|Business|(?:Glades\s)?(?:In)?[Cc]orp(?:orat(?:e|ion))?|Registered|Association)\s)(?:(?:[Ss]ervices?|[Cc]orporat(?:e|ion)|[aA]gents?|creations network|Filings)\s?)(?:System|Company)?/i =~ line_to_check
end
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 23 columns, instead of 6. in line 7.
First,Last,Company,Address,address2,City,State,Zip,Country,phone number,email address,Item#1/Name,Quantity#1,Item#2/Name,Quantity#2,Item#3/Name,Quantity#3,Item#4/Name,Quantity#4,Item#5/Name,Quantity#5,Item#6/Name,Quantity#6
John,Smith,,1234 Street Street,,SNOHOMISH,WA,98290-3643,UNITED STATES,(123)-456-(7890),John_smith@fake.com,,,,,English Map,1,,,,,,
John,Smith,,1235 Street Street,,Indianapolis,IN,46203,UNITED STATES,(123)-456-(7890),John_smith@fake.com,,,,,,,Spanish Map,1,,,,
John,Smith,,1236 Street Street,,Mequon,WI,53092,UNITED STATES,(123)-456-(7890),John_smith@fake.com,,,,,English Map,1,,,,,,
John,Smith,,1237 Street Street,,Midlothian,IL,60445,UNITED STATES,(123)-456-(7890),John_smith@fake.com,,,,,English Map,1,,,,,,
John,Smith,,1238 Street Street,,Barcelona,,8032,SPAIN,(123)-456-(7890),John_smith@fake.com,,,,,English Map,1,Spanish Map,1,,,,
John,Smith,,1239 Street Street,,port orange,FL,32127,UNITED STATES,(123)-456-(7890),John_smith@fake.com,,,,,English Map,1,,,,,,
John,Smith,,1240 Street Street,,bue
def ipd_seed(file, wo_number, pin_seq, dealer_pin, purl)
bill_first, john_first = "John #{wo_number}", 'John'
bill_address = '1234 street street'
john_address = '1234 street street'
bill_city, john_city = 'City', 'City'
bill_state = john_state = 'FL'
bill_zip5, john_zip5 = '33773', '33619'
bill_zip4, john_zip4 = '3047', '8315'
bill_purl = "johnsmith#{purl}"
john_purl = "johnsmith#{purl}"
require 'csv'
require './pallet_flag_generator.rb'
require 'ruby-progressbar'
def ipd_month_code(workOrder)
workOrder[0, 7]
end
def next_work_order_number(workOrder)
workOrder[-3, 3] = next_work_order_seq(workOrder)
describe Address do
it {should validate_presence_of(:address1)}
it {should validate_presence_of(:city)}
it {should validate_presence_of(:state)}
it {should validate_presence_of(:zip)}
it {should validate_uniqueness_of(:address1).scoped_to(:address2, :city, :state)}
end
@JasonMadeSomething
JasonMadeSomething / example_data
Last active August 29, 2015 14:26
Problematic regex
Crain Ford Jax 1 of 2
Peruzzi Mazda 1 of 2
@JasonMadeSomething
JasonMadeSomething / collector.rb
Last active August 29, 2015 14:26
Reek says feature envy.
module IPDUtils
# Class to handle outputting to console and collecting user data
class Collector
def starting_wo_number
print 'Enter first workorder in sequence: '
gets.chomp
end
def dealer_pin
print 'Enter dealer PIN: '