using python need take contents of text file e.g
http://pastebin.com/raw.php?i=dsbg6ud8 (the text file)
python code open file
file = open('file.txt', 'r') now need take each section separated "------------------" , rearrange own line in format of "internal://user:class@id". internal constant exists in new file not old , user, class , id taken old file.
unfortunately don't know how this, please help?
i'm not giving code, 1 of ways of doing it.
- iterate through file.
- if
line == "------------------", implies new set of data going start. hence create blank data structure in store upcoming data. (eg-dict) - else: split line on
":"character. , store first part key, , second part value of dict. - finally using dict, print desired output in new file.
if have doubts regarding how implement these individual steps, google/so it. i'm sure you'll find answers.
Comments
Post a Comment