Commits

Alex Ulianytskyi  committed c4ed0a3

Исправлен regexp для создание CSV

  • Participants
  • Parent commits 0d26c25

Comments (0)

Files changed (1)

 
 desc "Copy final PDFs to #{DISTDIR}"
 directory DISTDIR
-task :default do
+task :dist do
     FileList["#{DISTDIR}/*"].each do |f|
         File.delete(f)
     end
 
 desc "Make CSV file from raw spectrum files"
 task :make_csv do
-  if ARGV.count > 1
-    lab_no = ARGV.pop
+  if ENV['lab']:
+    lab_no = ENV['lab']
     chdir lab_no
   else
     puts "Lab # is required"
   end
   src_dir = "source"
   csv_dir = "source_csv"
-  mkdir_p csv_dir
+  regexp = /\d{3}\.\d{6}\s+[-0-9]{1,3}\.\d+/
+  mkdir_p "#{csv_dir}"
   FileList["#{src_dir}/*"].each do |f|
-    dest_f = "#{csv_dir}/#{File.basename(f, '.sca')}.csv"
-    `grep '^[0-9.,]+ [0-9.,]+' #{f} > #{dest_f}`
+    dest_f = "#{csv_dir}/#{File.basename(f)}.csv"
+    sh "grep --color=no -P '#{regexp}' '#{f}' > '#{dest_f}'"
   end
 end
+
+task :default => :dist