Skip to content

Instantly share code, notes, and snippets.

@timothy-allan
Created July 7, 2019 17:51
Show Gist options
  • Save timothy-allan/73fd19b53ddd05771b3ecb4d286b0308 to your computer and use it in GitHub Desktop.
Save timothy-allan/73fd19b53ddd05771b3ecb4d286b0308 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 6 14:33:28 2019
@author: timallan
"""
import random
origFile = open('/Users/timallan/Desktop/whiteFang/WhiteFangOriginal.txt', 'r')
saveFile = open('/Users/timallan/Desktop/whiteFang/wF_03.txt', 'w')
origLines = origFile.readlines()
cutLines = []
for aLine in origLines:
cutLine = []
singleLineList = aLine.split()
for aWord in singleLineList:
randNum = random.randrange(0, 101)
if randNum > 59:
cutLine.append(aWord)
cutString = ' '.join(cutLine)
cutLines.append(cutString)
cutFinalString = '\n'.join(cutLines)
print(cutFinalString)
print(len(cutFinalString))
saveFile.write(cutFinalString)
origFile.close()
saveFile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment