Class: ReVIEW::Retrovert::Utils
- Inherits:
-
Object
- Object
- ReVIEW::Retrovert::Utils
- Defined in:
- lib/review/retrovert/utils.rb
Class Method Summary collapse
- .GenerateTsv(c) ⇒ Object
- .NormalizeCSVArray(ar) ⇒ Object
-
.Tsv2Csv(infile, outfile) ⇒ Object
tsv to csv.
Class Method Details
.GenerateTsv(c) ⇒ Object
28 29 30 |
# File 'lib/review/retrovert/utils.rb', line 28 def GenerateTsv(c) CSV.generate_line(Utils::NormalizeCSVArray(c), col_sep: "\t") end |
.NormalizeCSVArray(ar) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/review/retrovert/utils.rb', line 19 def NormalizeCSVArray(ar) ar&.each do |c| c.gsub!(/\A"|"\z/, '') c.gsub!(/^\s*/, '') c.gsub!(/[\r\n]/, '') end ar end |
.Tsv2Csv(infile, outfile) ⇒ Object
tsv to csv
9 10 11 12 13 14 15 16 17 |
# File 'lib/review/retrovert/utils.rb', line 9 def Tsv2Csv(infile, outfile) File.open(infile, 'r') do |file| CSV.open(outfile, 'w') do |csv| file.each_line do |line| csv << line.chomp.split(/\t+/) end end end end |