From 715236b5b495d64f9f21a3c2ef80e387aba431da Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 15 Aug 2020 19:42:18 +0900 Subject: [PATCH] Improve comments --- lib/uplot/command.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/uplot/command.rb b/lib/uplot/command.rb index 6932aa9..7131e9a 100644 --- a/lib/uplot/command.rb +++ b/lib/uplot/command.rb @@ -275,12 +275,14 @@ module Uplot end def preprocess(input) - data = CSV.parse(input, col_sep: @delimiter) - data.delete([]) # Remove blank lines. - data.delete_if { |i| i.all? nil } # Room for improvement. - p parsed_csv: data if @debug - headers = get_headers(data) - data = get_data(data) + arr = CSV.parse(input, col_sep: @delimiter) + # Remove blank lines. + arr.delete([]) + # Remove rows where all elements are nil + arr.delete_if { |i| i.all? nil } + p parsed_csv: arr if @debug + headers = get_headers(arr) + data = get_data(arr) [data, headers] end