Sha256: 94f0e9d08338570a1075d36a4013b1ce77803f79ea385cd8f0e4509fb6c002d8
Contents?: true
Size: 1.22 KB
Versions: 10
Compression:
Stored size: 1.22 KB
Contents
require 'fileutils' require 'escape' class RemoteTable class Format module Textual def convert_file_to_utf8! ::RemoteTable.executor.bang t.local_file.path, "iconv -c -f #{::Escape.shell_single_word t.properties.encoding} -t UTF-8" end USELESS_CHARACTERS = [ '\xef\xbb\xbf', # UTF-8 byte order mark '\xc2\xad' # soft hyphen, often inserted by MS Office (html: ­) ] def remove_useless_characters! ::RemoteTable.executor.bang t.local_file.path, "perl -pe 's/#{USELESS_CHARACTERS.join '//g; s/'}//g'" end def skip_rows! return unless t.properties.skip > 0 ::RemoteTable.executor.bang t.local_file.path, "tail -n +#{t.properties.skip + 1}" end def crop_rows! return unless t.properties.crop ::RemoteTable.executor.bang t.local_file.path, "tail -n +#{::Escape.shell_single_word t.properties.crop.first.to_s} | head -n #{t.properties.crop.last - t.properties.crop.first + 1}" end def cut_columns! return unless t.properties.cut ::RemoteTable.executor.bang t.local_file.path, "cut -c #{::Escape.shell_single_word t.properties.cut.to_s}" end end end end
Version data entries
10 entries across 10 versions & 1 rubygems