I'm relatively new to Python (using v2.7.3) and I decided to test my skills out with editing a text document comprised of all the texts I've received on my phone. I want to edit out the useless information so I wrote a script to do that, but all the spaces between words are being deleted.
Here's a sample of the input data:
sms protocol="932" address="XXXXXXXXXX" date="1305655717379" type="1" subject="null" body="Talk to joey?" toa="null" sc_toa="null" service_center="null" read="1" status="-1" locked="0" date_sent="null" readable_date="May 17, 2011 2:08:37 PM" contact_name="David XXXX" />
Here's a sample of the output data:
body="Talktojoey?"toa="null"sc_toa="null"service_center="null"read="1"status="-1"locked="0"date_sent="null"readable_date="May17,20112:08:37PM"contact_name="DavidXXXX/>
Here's my code:
line= textfile.readline()
for line in textfile:
line = line.strip()
line = line.split(' ')
del line[0:6]
line.append("\n")
print line
output.writelines(line)
textfile.close()
output.close()
Any help on how to add spaces would be greatly appreciated. Thanks!
line = line[7:]