Split words and creating new files with different names

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jan Fink

    Split words and creating new files with different names

    I need to write a program like this: Write a program that reads a file .picasa.ini and copies pictures in new files, whose names are the same as identification numbers of person on these pictures (eg. 8ff985a43603dbf 8.jpg). If there are more person on the picture it makes more copies. If a person is on more pictures, later override earlier copies of pictures; if a person 8ff985a43603dbf 8 may appear in more pictures, only one file with this name will exist. You must presume that we have a simple file .picasa.ini.

    I have an .ini, that consists:

    [img_8538.jpg] faces=rect64(4a c022d1820c8624) ,d5a2d2f6f0d7cc bc backuphash=4651 2

    [img_8551.jpg] faces=rect64(ac b64583d1eb84cb) ,2623af3d8cb8e0 40;rect64(58bf4 41388df9592),d8 5d127e5c45cdc2 backuphash=8108 ...

    Is this a good way to start this program?

    Code:
    for line in open('C:\Users\Admin\Desktop\podatki-picasa\.picasa.ini'):
        if line.startswith('faces'):
            line.split() # what must I do here to split the bolded words?
    Is there a better way to do this? Remember the .jpg file must be created with a new name, so I think I should link the current .jpg file with the bolded one.
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    The start/stop characters are "(),;" and possibly a space but I can't really tell. You would probably have to parse the line one character at a time and "split" it yourself on those characters, keeping the groups that started with a left parens or a comma.

    Comment

    Working...