SHARE
TWEET

Untitled

a guest Mar 4th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Um Dateien zu splitten
  2.  
  3. infile = ARGV[0] if ARGV[0] != nil
  4.  
  5. counter = 1
  6. index = 0
  7. header = ""
  8.  
  9. writer = open(infile.gsub(/\./,"_part_"+counter.to_s+"."),'w')
  10.  
  11. file = open( infile, 'r')
  12.  
  13. file.each do | row |
  14.     if(index != 0 && index % 150 == 0)
  15.         writer.close
  16.         counter +=1
  17.         writer = open(infile.gsub(/\./,"_part_"+counter.to_s+"."),'w')
  18.         writer << header
  19.     end
  20.     if index == 0
  21.         header = row
  22.     end
  23.     writer << row
  24.     index +=1
  25. end
  26. writer.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top