-
Notifications
You must be signed in to change notification settings - Fork 0
/
looper.rb
28 lines (26 loc) · 887 Bytes
/
looper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def processFile(file,folder,root)
puts "Processing "+file+" from "+folder
name=folder+"_"+file.split(".")[0]
system("ruby parser.rb -o "+root+folder+"/"+file)
end
root=ARGV[0]
#Dir.mkdir "groupDir/" unless File.exists?("groupDir/")
puts "Give proper input" if root==nil
folders=Dir.entries(root).select {|f| f!="." and f!=".."} rescue folders=Array.new
sitesCrawled=0
threads=Array.new
for folder in folders
sitesDir=Dir.entries(root+folder) rescue sitesDir=Array.new
if sitesDir.size!=0
for file in sitesDir.select {|f| f.include? ".csv" or f.include? ".out"}
if File.exist? (root+folder+"/"+file)
processFile(file,folder,root)
#t=Thread.new{processFile(file,folder,root)}
# threads.push(t)
sitesCrawled+=1
end
end
end
end
#threads.each{|t| t.join}
puts sitesDir.size.to_s+" folders were parsed "+sitesCrawled.to_s+" sitesDir were processed"