prune-erickson 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/prune-erickson +445 -327
  3. data/lib/prune-erickson.rb +555 -127
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4510d52eb40bda3fa258d64f1f3bff97ab117fa0
4
- data.tar.gz: da9fe14ed126bf5ec839a78b94f653b95d12540c
3
+ metadata.gz: b7da5d2431577e893d44b2d9c121bd8b2a1021bf
4
+ data.tar.gz: 573a11a3d95cd34a874b5a3b9ca9b388abeb6791
5
5
  SHA512:
6
- metadata.gz: 86aabce24669f25b7b796f3a6db5bcc6a939938f0dfac557c486c1bffe3f6a91f728260d8b849c04c4c07c513f67b84ab5aac6de08eb9e501e88c3f5ab268f17
7
- data.tar.gz: 9e02f8ed112fc9feb2dee674fc423c2d930f26058cf271d1d80fd837ea76735f40225b8f3c34cfef45ae054410a59e5c2044c8189ed9fc490c575ad6754196ff
6
+ metadata.gz: 2d418b17843bcad101a17f19354f7a2c80f6078e1334edebdbe903c1a43b4b2b73d8a60e8586b4a80ac5b05c7c2c9bf327de24d51e0522935c89d1cc40c9e248
7
+ data.tar.gz: c8c105c3034bc95b3b162d03ae9f8167c3e6420190df793fb8495405e643862f060504bbee62f5209d38bed20ea09f8ccf67f7a76921d8a9bf6778ed37c0027c
data/bin/prune-erickson CHANGED
@@ -6,18 +6,427 @@ require 'colorize'
6
6
  # require 'fileUtils'
7
7
 
8
8
 
9
+ # ------------------
10
+ # FUNCTIONS
11
+ # ------------------
12
+
13
+
14
+
15
+ def labelChecker (row, testvar)
16
+
17
+ row.each_with_index{|val, index|
18
+
19
+ unless val != "OppCommunity" and val !="FirstName" and val != "LastName" and val != "Address" and val!="City" and val != "State" and val != "Zipcode" and val != "Phone" and val != "Email" and val != "ILorCC"
20
+ testvar.push(index)
21
+ end
22
+ }
23
+ end
24
+
25
+ def fieldChecker (row)
26
+ unless row.include? "OppCommunity"
27
+ print "you are missing the OppCommunity field\n".yellow.blink
28
+ else
29
+ end
30
+ unless row.include? "FirstName"
31
+ print "you are missing the FirstName field\n".yellow.blink
32
+ end
33
+ unless row.include? "LastName"
34
+ print "you are missing the LastName field\n".yellow.blink
35
+ end
36
+ unless row.include? "Phone"
37
+ print "you are missing the phone field\n".yellow.blink
38
+ end
39
+ unless row.include? "Address"
40
+ print "you are missing the Address field\n".yellow.blink
41
+ end
42
+ unless row.include? "City"
43
+ print "you are missing the City field\n".yellow.blink
44
+ end
45
+ unless row.include? "State"
46
+ print "you are missing the State field\n".yellow.blink
47
+ end
48
+ unless row.include? "Zipcode"
49
+ print "you are missing the Zipcode field\n".yellow.blink
50
+ end
51
+ unless row.include? "Address"
52
+ print "you are missing the Address field\n".yellow.blink
53
+ end
54
+ unless row.include? "Address"
55
+ print "you are missing the Address field\n".yellow.blink
56
+ end
57
+ unless row.include? "Email"
58
+ print "you are missing the Email field\n".yellow.blink
59
+ end
60
+ end
61
+
62
+ def processData (sheet, newvar, testvar)
63
+
64
+ newvar.push "zero"
65
+ sheet.each do |row|
66
+ row.each_with_index {|val, index|
67
+ if testvar.include? index
68
+
69
+ newvar.push val
70
+ end
71
+ }
72
+ end
73
+ print "~~>writing new file \n\n"
74
+
75
+ newvar.map! { |x|
76
+
77
+ if x == "OppCommunity"
78
+ print "renaming field #{x} \n".colorize(:light_blue)
79
+ x = "Community of Interest"
80
+ elsif x == "FirstName"
81
+ print "renaming field #{x} \n".colorize(:light_blue)
82
+ x = "First Name"
83
+ elsif x == "LastName"
84
+ print "renaming field #{x} \n".colorize(:light_blue)
85
+ x = "Last Name"
86
+ elsif x == "Address"
87
+ print "renaming field #{x} \n".colorize(:light_blue)
88
+ x = "Address 1"
89
+ elsif x == "city"
90
+ print "renaming field #{x} \n".colorize(:light_blue)
91
+ x = "city"
92
+ elsif x == "State"
93
+ print "renaming field #{x} \n".colorize(:light_blue)
94
+ x = "State or Province"
95
+ elsif x == "Zipcode"
96
+ print "renaming field #{x} \n".colorize(:light_blue)
97
+ x = "Zip or Postal Code"
98
+ elsif x == "Email"
99
+ print "renaming field #{x} \n".colorize(:light_blue)
100
+ x = "Email Address"
101
+ elsif x == "Phone"
102
+ print "renaming field #{x} \n".colorize(:light_blue)
103
+ x = "Home Phone"
104
+ else
105
+ x=x
106
+ end
107
+ }
108
+ end
109
+
110
+ def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0)
111
+ # print newvar
112
+ newBook = Spreadsheet::Workbook.new
113
+ newSheet = newBook.create_worksheet
114
+ if il_or_cc == ""
115
+ testvar.each do |x|
116
+ newSheet.row(0).push x
117
+ end
118
+ end
119
+ for i in k..newvar.length
120
+ for j in l..testvar.length-1
121
+ newSheet.row(i+offset).push newvar[(i*testvar.length)+j]
122
+ end
123
+ if il_or_cc != ""
124
+ if i > 0
125
+ newSheet.row(i).push "#{il_or_cc}"
126
+
127
+ else
128
+ newSheet.row(i).push "ILorCC"
129
+ end
130
+ end
131
+ end
132
+ print "output file is in same file under out.xls to open, use \n \n open #{output}"
133
+ print "\n"
134
+ newBook.write output
135
+ end
136
+
137
+ def com_separated_files (output)
138
+ puts output
139
+ labels = Array.new
140
+ apl_array = Array.new
141
+ ach_array = Array.new
142
+ bbv_array = Array.new
143
+ ccv_array = Array.new
144
+ cci_array = Array.new
145
+ dvf_array = Array.new
146
+ eth_array = Array.new
147
+ frv_array = Array.new
148
+ gsv_array = Array.new
149
+ hsd_array = Array.new
150
+ lhn_array = Array.new
151
+ lph_array = Array.new
152
+ mgc_array = Array.new
153
+ ocv_array = Array.new
154
+ rwv_array = Array.new
155
+ sbv_array = Array.new
156
+ tck_array = Array.new
157
+ wcd_array = Array.new
158
+
159
+ original = Spreadsheet.open(output)
160
+ original_sheet = original.worksheet(0)
161
+
162
+
163
+ rowlength = original_sheet.row(0)
164
+ puts rowlength.length
165
+ # make a directory for the new files
166
+ unless File.directory?("com_separated_files")
167
+ %x(mkdir com_separated_files)
168
+ end
169
+ original_sheet.each do |row|
170
+ if row[0] == "apl".upcase
171
+
172
+ # print row to other array and print label to a community array
173
+ row.each do |x|
174
+ apl_array.push x
175
+ end
176
+ unless labels.include?("apl".upcase)
177
+ labels.push "apl".upcase
178
+ end
179
+ end
180
+ if row[0] == "ach".upcase
181
+
182
+ # print row to other array and print label to a community array
183
+ row.each do |x|
184
+ ach_array.push x
185
+ end
186
+ unless labels.include?("ach".upcase)
187
+ labels.push "ach".upcase
188
+ end
189
+ end
190
+ if row[0] == "bbv".upcase
191
+
192
+ # print row to other array and print label to a community array
193
+ row.each do |x|
194
+ bbv_array.push x
195
+ end
196
+ unless labels.include?("bbv".upcase)
197
+ labels.push "bbv".upcase
198
+ end
199
+ end
200
+ if row[0] == "ccv".upcase
201
+
202
+ # print row to other array and print label to a community array
203
+ row.each do |x|
204
+ ccv_array.push x
205
+ end
206
+ unless labels.include?("ccv".upcase)
207
+ labels.push "ccv".upcase
208
+ end
209
+ end
210
+ if row[0] == "cci".upcase
211
+
212
+ # print row to other array and print label to a community array
213
+ row.each do |x|
214
+ cci_array.push x
215
+ end
216
+ unless labels.include?("cci".upcase)
217
+ labels.push "cci".upcase
218
+ end
219
+ end
220
+ if row[0] == "dvf".upcase
221
+
222
+ # print row to other array and print label to a community array
223
+ row.each do |x|
224
+ dvf_array.push x
225
+ end
226
+ unless labels.include?("dvf".upcase)
227
+ labels.push "dvf".upcase
228
+ end
229
+ end
230
+ if row[0] == "eth".upcase
231
+
232
+ # print row to other array and print label to a community array
233
+ row.each do |x|
234
+ eth_array.push x
235
+ end
236
+ unless labels.include?("eth".upcase)
237
+ labels.push "eth".upcase
238
+ end
239
+ end
240
+ if row[0] == "frv".upcase
241
+
242
+ # print row to other array and print label to a community array
243
+ row.each do |x|
244
+ frv_array.push x
245
+ end
246
+ unless labels.include?("frv".upcase)
247
+ labels.push "frv".upcase
248
+ end
249
+ end
250
+ if row[0] == "gsv".upcase
251
+
252
+ # print row to other array and print label to a community array
253
+ row.each do |x|
254
+ gsv_array.push x
255
+ end
256
+ unless labels.include?("gsv".upcase)
257
+ labels.push "gsv".upcase
258
+ end
259
+ end
260
+ if row[0] == "hsd".upcase
261
+
262
+ # print row to other array and print label to a community array
263
+ row.each do |x|
264
+ hsd_array.push x
265
+ end
266
+ unless labels.include?("hsd".upcase)
267
+ labels.push "hsd".upcase
268
+ end
269
+ end
270
+ if row[0] == "lhn".upcase
271
+
272
+ # print row to other array and print label to a community array
273
+ row.each do |x|
274
+ lhn_array.push x
275
+ end
276
+ unless labels.include?("lhn".upcase)
277
+ labels.push "lhn".upcase
278
+ end
279
+ end
280
+ if row[0] == "lph".upcase
281
+
282
+ # print row to other array and print label to a community array
283
+ row.each do |x|
284
+ lph_array.push x
285
+ end
286
+ unless labels.include?("lph".upcase)
287
+ labels.push "lph".upcase
288
+ end
289
+ end
290
+ if row[0] == "mgc".upcase
291
+
292
+ # print row to other array and print label to a community array
293
+ row.each do |x|
294
+ mgc_array.push x
295
+ end
296
+ unless labels.include?("mgc".upcase)
297
+ labels.push "mgc".upcase
298
+ end
299
+ end
300
+ if row[0] == "ocv".upcase
301
+
302
+ # print row to other array and print label to a community array
303
+ row.each do |x|
304
+ ocv_array.push x
305
+ end
306
+ unless labels.include?("ocv".upcase)
307
+ labels.push "ocv".upcase
308
+ end
309
+ end
310
+ if row[0] == "rwv".upcase
311
+
312
+ # print row to other array and print label to a community array
313
+ row.each do |x|
314
+ rwv_array.push x
315
+ end
316
+ unless labels.include?("rwv".upcase)
317
+ labels.push "rwv".upcase
318
+ end
319
+ end
320
+ if row[0] == "sbv".upcase
321
+
322
+ # print row to other array and print label to a community array
323
+ row.each do |x|
324
+ sbv_array.push x
325
+ end
326
+ unless labels.include?("sbv".upcase)
327
+ labels.push "sbv".upcase
328
+ end
329
+ end
330
+ if row[0] == "tck".upcase
331
+
332
+ # print row to other array and print label to a community array
333
+ row.each do |x|
334
+ tck_array.push x
335
+ end
336
+ unless labels.include?("tck".upcase)
337
+ labels.push "tck".upcase
338
+ end
339
+ end
340
+ if row[0] == "wcd".upcase
341
+
342
+ # print row to other array and print label to a community array
343
+ row.each do |x|
344
+ wcd_array.push x
345
+ end
346
+ unless labels.include?("wcd".upcase)
347
+ labels.push "wcd".upcase
348
+ end
349
+ end
350
+ end
351
+ print "creating files for these communities:\n".blue
352
+ puts "#{labels}".blue
353
+ print rowlength
354
+ if apl_array.length > 0
355
+ printFile(apl_array, rowlength, "com_separated_files/apl.xls", "", 0, 0,1)
356
+ end
357
+ if ach_array.length > 0
358
+ printFile(ach_array, rowlength, "com_separated_files/ach.xls", "", 0, 0,1)
359
+ end
360
+ if bbv_array.length > 0
361
+ printFile(bbv_array, rowlength, "com_separated_files/bbv.xls", "", 0, 0,1)
362
+ end
363
+ if ccv_array.length > 0
364
+ printFile(ccv_array, rowlength, "com_separated_files/ccv.xls", "", 0, 0,1)
365
+ end
366
+ if cci_array.length > 0
367
+ printFile(cci_array, rowlength, "com_separated_files/cci.xls", "", 0, 0,1)
368
+ end
369
+ if dvf_array.length > 0
370
+ printFile(dvf_array, rowlength, "com_separated_files/dvf.xls", "", 0, 0,1)
371
+ end
372
+ if eth_array.length > 0
373
+ printFile(eth_array, rowlength, "com_separated_files/eth.xls", "", 0, 0,1)
374
+ end
375
+ if frv_array.length > 0
376
+ printFile(frv_array, rowlength, "com_separated_files/frv.xls", "", 0, 0,1)
377
+ end
378
+ if gsv_array.length > 0
379
+ printFile(gsv_array, rowlength, "com_separated_files/gsv.xls", "", 0, 0,1)
380
+ end
381
+ if hsd_array.length > 0
382
+ printFile(hsd_array, rowlength, "com_separated_files/hsd.xls", "", 0, 0,1)
383
+ end
384
+ if lhn_array.length > 0
385
+ printFile(lhn_array, rowlength, "com_separated_files/lhn.xls", "", 0, 0,1)
386
+ end
387
+ if lph_array.length > 0
388
+ printFile(lph_array, rowlength, "com_separated_files/lph.xls", "", 0, 0,1)
389
+ end
390
+ if mgc_array.length > 0
391
+ printFile(mgc_array, rowlength, "com_separated_files/mgc.xls", "", 0, 0,1)
392
+ end
393
+ if ocv_array.length > 0
394
+ printFile(ocv_array, rowlength, "com_separated_files/ocv.xls", "", 0, 0,1)
395
+ end
396
+ if rwv_array.length > 0
397
+ printFile(rwv_array, rowlength, "com_separated_files/rwv.xls", "", 0, 0,1)
398
+ end
399
+ if sbv_array.length > 0
400
+ printFile(sbv_array, rowlength, "com_separated_files/sbv.xls", "", 0, 0,1)
401
+ end
402
+ if tck_array.length > 0
403
+ printFile(tck_array, rowlength, "com_separated_files/tck.xls", "", 0, 0,1)
404
+ end
405
+ if wcd_array.length > 0
406
+ printFile(wcd_array, rowlength, "com_separated_files/wcd.xls", "", 0, 0,1)
407
+ end
408
+
409
+
410
+ end
411
+
9
412
  # --------------------------------------------
10
413
  # GRABS INFORMATION FROM COMMAND LINE AND MAKES DATA AVAILABLE FOR PROGRAM
11
414
  fileName = ARGV[0]
12
415
  sheetNum = ARGV[1].to_i-1
13
416
  output = ARGV[2]
14
- if sheetNum > 0
15
- print fileName
16
- print "\n"
417
+ print "\n\n"
418
+ print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
17
419
 
18
- print sheetNum
19
- end
420
+ res = STDIN.gets.strip
20
421
  print "\n\n"
422
+ if res == 'y' || res == 'Y'
423
+ il_or_cc = 'CC'
424
+ else
425
+ il_or_cc = "IL"
426
+ end
427
+ print "Do you wish to create separate files based on community names?[y/n]".yellow
428
+ comres= STDIN.gets.strip
429
+
21
430
  # --------------------------------------------
22
431
  # ASKING FOR HELP
23
432
  if ARGV.length == 1 and ARGV[0] == "help"
@@ -61,19 +470,19 @@ print "
61
470
  Stay tuned for the official release 1.0.0 which could be any
62
471
  day now.
63
472
  ".yellow
64
-
473
+ # --------------------------------------------
474
+ # if the user input has to do with the help or version options this code is run
65
475
  elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0] != '-version' or ARGV[0] != "-v"
66
- # if ~~~> catch different files and options before running code to check for errors.
67
- # \S+[.xls*] this is a regex for the xls input and output files
68
- # \s\S\s to pick up the index number
69
- # I should also check that book is not nil
476
+ # line 68 catches any user input that relates to .xls files in the form of
477
+ # prune-erickson yourfile.xls [digit] outputfile.xls
70
478
  if ARGV[0] =~ /\S+.xls\b/ and ARGV[1] =~ /\d/ and ARGV[2] =~ /\S+.xls\b/
71
- # --------------------------------------------
479
+
72
480
  Spreadsheet.client_encoding = 'UTF-8'
73
481
  print "~>reading file you have requested"
74
482
  print "\n"
483
+ # --------------------------------------------
75
484
  # reads file
76
-
485
+ #checking if the file is not nil and then creating a new workbook to copy necessary info into.
77
486
  if File.exist?(fileName.to_s)
78
487
  book = Spreadsheet.open fileName
79
488
  sheet1 = book.worksheet sheetNum
@@ -81,9 +490,8 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
81
490
  newSheet = newBook.create_worksheet
82
491
 
83
492
  newSheet.name = "output"
84
-
85
493
  testvar = Array.new
86
-
494
+ newvar = Array.new
87
495
  print "~>looking for unnecessary information"
88
496
  print "\n"
89
497
  if sheet1 == nil
@@ -92,110 +500,13 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
92
500
  this sheet seems to be empty...
93
501
  are you selecting the wrong one? \n".red
94
502
  else
95
- sheet1.row(0).each_with_index{|val, index|
96
-
97
- unless val != "OppCommunity" and val !="FirstName" and val != "LastName" and val != "Address" and val!="City" and val != "State" and val != "Zipcode" and val != "Phone" and val != "Email" and val != "ILorCC"
98
- testvar.push(index)
99
- end
100
- }
101
-
102
- unless sheet1.row(0).include? "OppCommunity"
103
- print "you are missing the OppCommunity field\n".yellow.blink
104
- else
105
-
106
- end
107
- unless sheet1.row(0).include? "FirstName"
108
- print "you are missing the FirstName field\n".yellow.blink
109
- end
110
- unless sheet1.row(0).include? "LastName"
111
- print "you are missing the LastName field\n".yellow.blink
112
- end
113
- unless sheet1.row(0).include? "Phone"
114
- print "you are missing the phone field\n".yellow.blink
115
- end
116
- unless sheet1.row(0).include? "Address"
117
- print "you are missing the Address field\n".yellow.blink
118
- end
119
- unless sheet1.row(0).include? "City"
120
- print "you are missing the City field\n".yellow.blink
121
- end
122
- unless sheet1.row(0).include? "State"
123
- print "you are missing the State field\n".yellow.blink
503
+ labelChecker(sheet1.row(0), testvar)
504
+ fieldChecker(sheet1.row(0))
505
+ processData(sheet1, newvar, testvar)
506
+ printFile(newvar, testvar, output, il_or_cc)
507
+ if comres == 'y' || comres == 'Y'
508
+ com_separated_files(output)
124
509
  end
125
- unless sheet1.row(0).include? "Zipcode"
126
- print "you are missing the Zipcode field\n".yellow.blink
127
- end
128
- unless sheet1.row(0).include? "Address"
129
- print "you are missing the Address field\n".yellow.blink
130
- end
131
- unless sheet1.row(0).include? "Address"
132
- print "you are missing the Address field\n".yellow.blink
133
- end
134
- unless sheet1.row(0).include? "Email"
135
- print "you are missing the Email field\n".yellow.blink
136
- end
137
- # puts testvar
138
- newvar = Array.new
139
- newvar.push "zero"
140
- sheet1.each do |row|
141
- row.each_with_index {|val, index|
142
- if testvar.include? index
143
-
144
- newvar.push val
145
- end
146
- }
147
- end
148
- print "~~>writing new file \n\n"
149
-
150
- newvar.map! { |x|
151
-
152
- if x == "OppCommunity"
153
- print "renaming field #{x} \n".colorize(:light_blue)
154
- x = "Community of Interest"
155
- elsif x == "FirstName"
156
- print "renaming field #{x} \n".colorize(:light_blue)
157
- x = "First Name"
158
- elsif x == "LastName"
159
- print "renaming field #{x} \n".colorize(:light_blue)
160
- x = "Last Name"
161
- elsif x == "Address"
162
- print "renaming field #{x} \n".colorize(:light_blue)
163
- x = "Address 1"
164
- elsif x == "city"
165
- print "renaming field #{x} \n".colorize(:light_blue)
166
- x = "city"
167
- elsif x == "State"
168
- print "renaming field #{x} \n".colorize(:light_blue)
169
- x = "State or Province"
170
- elsif x == "Zipcode"
171
- print "renaming field #{x} \n".colorize(:light_blue)
172
- x = "Zip or Postal Code"
173
- elsif x == "Email"
174
- print "renaming field #{x} \n".colorize(:light_blue)
175
- x = "Email Address"
176
- elsif x == "Phone"
177
- print "renaming field #{x} \n".colorize(:light_blue)
178
- x = "Home Phone"
179
- else
180
- x=x
181
- end
182
- }
183
- # print newvar
184
- for i in 0..newvar.length
185
- for j in 1..testvar.length
186
-
187
-
188
- newSheet.row(i).push newvar[(i*testvar.length)+j]
189
- end
190
- if i > 0
191
- newSheet.row(i).push "IL"
192
- else
193
- newSheet.row(i).push "ILorCC"
194
- end
195
- end
196
- print "output file is in same file under out.xls to open, use \n \n open #{output}"
197
- print "\n"
198
- newBook.write output
199
510
  end
200
511
  else
201
512
  print "\n\n
@@ -214,115 +525,17 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
214
525
  newSheet.name = "output"
215
526
 
216
527
  testvar = Array.new
217
-
528
+ newvar = Array.new
218
529
  print "~>looking for unnecessary information"
219
530
  print "\n"
220
531
 
221
- file_data[0].each_with_index{|val, index|
222
-
223
- unless val != "OppCommunity" and val !="FirstName" and val != "LastName" and val != "Address" and val!="City" and val != "State" and val != "Zipcode" and val != "Phone" and val != "Email" and val != "ILorCC"
224
- testvar.push(index)
225
- end
226
- }
227
-
228
- unless file_data[0].include? "OppCommunity"
229
- print "you are missing the OppCommunity field\n".yellow.blink
230
- else
231
-
232
- end
233
- unless file_data[0].include? "FirstName"
234
- print "you are missing the FirstName field\n".yellow.blink
235
- end
236
- unless file_data[0].include? "LastName"
237
- print "you are missing the LastName field\n".yellow.blink
238
- end
239
- unless file_data[0].include? "Phone"
240
- print "you are missing the phone field\n".yellow.blink
241
- end
242
- unless file_data[0].include? "Address"
243
- print "you are missing the Address field\n".yellow.blink
244
- end
245
- unless file_data[0].include? "City"
246
- print "you are missing the City field\n".yellow.blink
247
- end
248
- unless file_data[0].include? "State"
249
- print "you are missing the State field\n".yellow.blink
532
+ labelChecker(file_data[0], testvar)
533
+ fieldChecker(file_data[0])
534
+ processData(file_data, newvar, testvar)
535
+ printFile(newvar, testvar, output, il_or_cc)
536
+ if comres == 'y' || comres == 'Y'
537
+ com_separated_files(output)
250
538
  end
251
- unless file_data[0].include? "Zipcode"
252
- print "you are missing the Zipcode field\n".yellow.blink
253
- end
254
- unless file_data[0].include? "Address"
255
- print "you are missing the Address field\n".yellow.blink
256
- end
257
- unless file_data[0].include? "Address"
258
- print "you are missing the Address field\n".yellow.blink
259
- end
260
- unless file_data[0].include? "Email"
261
- print "you are missing the Email field\n".yellow.blink
262
- end
263
- # puts testvar
264
- newvar = Array.new
265
- newvar.push "zero"
266
- file_data.each do |row|
267
- row.each_with_index {|val, index|
268
- if testvar.include? index
269
-
270
- newvar.push val
271
- end
272
- }
273
- end
274
- print "~~>writing new file \n\n"
275
-
276
- newvar.map! { |x|
277
-
278
- if x == "OppCommunity"
279
- print "renaming field #{x} \n".colorize(:light_blue)
280
- x = "Community of Interest"
281
- elsif x == "FirstName"
282
- print "renaming field #{x} \n".colorize(:light_blue)
283
- x = "First Name"
284
- elsif x == "LastName"
285
- print "renaming field #{x} \n".colorize(:light_blue)
286
- x = "Last Name"
287
- elsif x == "Address"
288
- print "renaming field #{x} \n".colorize(:light_blue)
289
- x = "Address 1"
290
- elsif x == "city"
291
- print "renaming field #{x} \n".colorize(:light_blue)
292
- x = "city"
293
- elsif x == "State"
294
- print "renaming field #{x} \n".colorize(:light_blue)
295
- x = "State or Province"
296
- elsif x == "Zipcode"
297
- print "renaming field #{x} \n".colorize(:light_blue)
298
- x = "Zip or Postal Code"
299
- elsif x == "Email"
300
- print "renaming field #{x} \n".colorize(:light_blue)
301
- x = "Email Address"
302
- elsif x == "Phone"
303
- print "renaming field #{x} \n".colorize(:light_blue)
304
- x = "Home Phone"
305
- else
306
- x=x
307
- end
308
- }
309
- # print newvar
310
- for i in 0..newvar.length
311
- for j in 1..testvar.length
312
-
313
-
314
- newSheet.row(i).push newvar[(i*testvar.length)+j]
315
- end
316
- if i > 0
317
- newSheet.row(i).push "IL"
318
- else
319
- newSheet.row(i).push "ILorCC"
320
- end
321
- end
322
- print "output file is in same file under out.xls to open, use \n \n open #{output}"
323
- print "\n"
324
- newBook.write output
325
-
326
539
  else
327
540
  print "\n\n
328
541
  WHOOPS!!!
@@ -343,7 +556,8 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
343
556
  xlsx = Roo::Spreadsheet.open(fileName)
344
557
  newBook = Spreadsheet::Workbook.new
345
558
  newSheet = newBook.create_worksheet
346
- if xlsx.sheet(sheetNum) == nil
559
+ xlsxSheet = xlsx.sheet(sheetNum)
560
+ if xlsxSheet == nil
347
561
  print "\n
348
562
  (_(T__T)_/ \n\n
349
563
  this sheet seems to be empty...
@@ -354,110 +568,14 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
354
568
  # take first row, and loop through the items in the array
355
569
  # sort indexes that are not necessary in the array
356
570
  testvar = Array.new
357
- header.each_with_index{|val, index|
358
- unless val != "OppCommunity" and val !="FirstName" and val != "LastName" and val != "Address" and val!="City" and val != "State" and val != "Zipcode" and val != "Phone" and val != "Email" and val != "ILorCC"
359
- testvar.push(index)
360
- end
361
- }
362
-
363
- # check for missing necessary information
364
- unless header.include? "OppCommunity"
365
- print "you are missing the OppCommunity field\n".yellow.blink
366
- else
367
-
368
- end
369
- unless header.include? "FirstName"
370
- print "you are missing the FirstName field\n".yellow.blink
371
- end
372
- unless header.include? "LastName"
373
- print "you are missing the LastName field\n".yellow.blink
374
- end
375
- unless header.include? "Phone"
376
- print "you are missing the phone field\n".yellow.blink
571
+ newvar = Array.new
572
+ labelChecker(header, testvar)
573
+ fieldChecker(header)
574
+ processData(xlsxSheet, newvar, testvar)
575
+ printFile(newvar, testvar, output, il_or_cc)
576
+ if comres == 'y' || comres == 'Y'
577
+ com_separated_files(output)
377
578
  end
378
- unless header.include? "Address"
379
- print "you are missing the Address field\n".yellow.blink
380
- end
381
- unless header.include? "City"
382
- print "you are missing the City field\n".yellow.blink
383
- end
384
- unless header.include? "State"
385
- print "you are missing the State field\n".yellow.blink
386
- end
387
- unless header.include? "Zipcode"
388
- print "you are missing the Zipcode field\n".yellow.blink
389
- end
390
- unless header.include? "Address"
391
- print "you are missing the Address field\n".yellow.blink
392
- end
393
- unless header.include? "Address"
394
- print "you are missing the Address field\n".yellow.blink
395
- end
396
- unless header.include? "Email"
397
- print "you are missing the Email field\n".yellow.blink
398
- end
399
-
400
- # puts testvar
401
- newvar = Array.new
402
- newvar.push "zero"
403
- xlsx.sheet(sheetNum).each do |row|
404
- row.each_with_index {|val, index|
405
- if testvar.include? index
406
-
407
- newvar.push val
408
- end
409
- }
410
- end
411
- print "~~>writing new file \n\n"
412
-
413
- newvar.map! { |x|
414
-
415
- if x == "OppCommunity"
416
- print "renaming field #{x} \n".colorize(:light_blue)
417
- x = "Community of Interest"
418
- elsif x == "FirstName"
419
- print "renaming field #{x} \n".colorize(:light_blue)
420
- x = "First Name"
421
- elsif x == "LastName"
422
- print "renaming field #{x} \n".colorize(:light_blue)
423
- x = "Last Name"
424
- elsif x == "Address"
425
- print "renaming field #{x} \n".colorize(:light_blue)
426
- x = "Address 1"
427
- elsif x == "city"
428
- print "renaming field #{x} \n".colorize(:light_blue)
429
- x = "city"
430
- elsif x == "State"
431
- print "renaming field #{x} \n".colorize(:light_blue)
432
- x = "State or Province"
433
- elsif x == "Zipcode"
434
- print "renaming field #{x} \n".colorize(:light_blue)
435
- x = "Zip or Postal Code"
436
- elsif x == "Email"
437
- print "renaming field #{x} \n".colorize(:light_blue)
438
- x = "Email Address"
439
- elsif x == "Phone"
440
- print "renaming field #{x} \n".colorize(:light_blue)
441
- x = "Home Phone"
442
- else
443
- x=x
444
- end
445
- }
446
- for i in 0..newvar.length
447
- for j in 1..testvar.length
448
-
449
-
450
- newSheet.row(i).push newvar[(i*testvar.length)+j]
451
- end
452
- if i > 0
453
- newSheet.row(i).push "IL"
454
- else
455
- newSheet.row(i).push "ILorCC"
456
- end
457
- end
458
- print "output file is in same file under out.xls to open, use \n \n open #{output}"
459
- print "\n"
460
- newBook.write output
461
579
  end
462
580
  end
463
581
  else
@@ -467,4 +585,4 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
467
585
  prune-erickson help \n\n\n
468
586
  "
469
587
  end
470
- end
588
+ end