Skip to content

Instantly share code, notes, and snippets.

@minthemiddle
Last active August 29, 2015 14:00
Show Gist options
  • Save minthemiddle/11186525 to your computer and use it in GitHub Desktop.
Save minthemiddle/11186525 to your computer and use it in GitHub Desktop.
Simple line split and string removal/slice from the end of file
import os
string = """
Introduction 03:39
How to sell your websites for $15,000 09:16
SECTION 2: BEATING THE COMPETITION: HOW TO DIFFERENTIATE YOUR WEB DESIGN SERVICES
"""
stringSplit = ''
stringNewlineBreak = string.split('\n')
for n in stringNewlineBreak:
stringSplit += n[:-6] + '\n'
stringSplitCleaned = os.linesep.join(
[s for s in stringSplit.splitlines() if s])
print stringSplitCleaned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment