Created
July 8, 2019 12:42
-
-
Save timothy-allan/4f11e68b8b14d8db135ed2d7602d485d to your computer and use it in GitHub Desktop.
Experiments in deletion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/03_inDESIGN/_TXT/WhiteFangOriginal.txt', 'r') | |
saveFile = open('/Users/timallan/Desktop/whiteFang/03_inDESIGN/_TXT/wF_06.txt', 'w') | |
origLines = origFile.readlines() | |
cutLines = [] | |
for aLine in origLines: | |
singleLine = aLine.split() | |
origLineLen = len(singleLine) | |
targetLineLen = int(origLineLen * 0.41) | |
while origLineLen > targetLineLen: | |
randNum = random.randrange(0, origLineLen) | |
singleLine.pop(randNum) | |
origLineLen -= 1 | |
cutString = ' '.join(singleLine) | |
cutLines.append(cutString) | |
cutFinalString = '\n'.join(cutLines) | |
print(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