class Cleaner
Public Class Methods
split()
click to toggle source
# File lib/cli_csv.rb, line 38 def self.split rows = 0 path = '' until rows >= 1 print "How many rows do you want in your resulting files?: " rows = gets.chomp.to_i end until File.file? path print "What's the name of your master file? Type the name or drag it onto terminal: " path = gets.chomp.strip path.end_with?('.csv') ? path : path = "#{path}.csv" unless File.file? path puts "File not found.\nTry retyping the filename, using the full path or moving to its directory and try again." end end split = Splitter.split(path, rows) self.start end
start()
click to toggle source
# File lib/cli_csv.rb, line 6 def self.start puts "What do you want to do?" puts "1. Split a single CSV into smaller ones" puts "2. Split a bunch of CSVs into smaller ones" puts "3. Remove duplicate rows from a CSV" puts "4. Remove empty rows from a CSV" puts "5. Delete CSV files from a directory that have few (or no) rows" puts "6. Detect rows in a CSV that have a cell with too much text" puts "7. Find a substring in a cell of a CSV" decision = 0 until decision >= 1 && decision <= 7 print "Enter a number: " decision = gets.chomp.to_i end case decision when 1 self.split when 2 puts "Coming soon!" when 3 puts "Coming soon!" when 4 puts "Coming soon!" when 5 puts "Coming soon!" when 6 puts "Coming soon!" when 7 puts "Coming soon!" end end