Alex Ulianytskyi avatar Alex Ulianytskyi committed c4ed0a3

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

Comments (0)

Files changed (1)

 desc "Copy final PDFs to #{DISTDIR}"
 directory DISTDIR
-task :default do
+task :dist do
     FileList["#{DISTDIR}/*"].each do |f|
 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
     puts "Lab # is required"
   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}'"
+task :default => :dist
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.