SHARE
TWEET

Untitled

a guest Jul 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Sat Jul  6 14:33:28 2019
  5. @author: timallan
  6. """
  7. import random
  8.  
  9. origFile = open('/Users/timallan/Desktop/whiteFang/03_inDESIGN/_TXT/WhiteFangOriginal.txt', 'r')
  10. saveFile = open('/Users/timallan/Desktop/whiteFang/03_inDESIGN/_TXT/wF_06.txt', 'w')
  11.  
  12. origLines = origFile.readlines()
  13.  
  14. cutLines = []
  15.  
  16. for aLine in origLines:
  17.     singleLine = aLine.split()
  18.     origLineLen = len(singleLine)
  19.     targetLineLen = int(origLineLen * 0.41)
  20.        
  21.     while origLineLen > targetLineLen:
  22.         randNum = random.randrange(0, origLineLen)
  23.        
  24.         singleLine.pop(randNum)
  25.         origLineLen -= 1
  26.        
  27.     cutString = ' '.join(singleLine)    
  28.     cutLines.append(cutString)
  29.  
  30. cutFinalString = '\n'.join(cutLines)
  31.  
  32. print(cutFinalString)
  33. saveFile.write(cutFinalString)
  34.  
  35.  
  36. origFile.close()
  37. saveFile.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
 
Top