By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

Split words and creating new files with different names

P: n/a
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. 8ff985a43603dbf8.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 8ff985a43603dbf8 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(4ac022d1820c8624),d5a2d2f6f0d7ccbc backuphash=46512

[img_8551.jpg] faces=rect64(acb64583d1eb84cb),2623af3d8cb8e040;re ct64(58bf441388df9592),d85d127e5c45cdc2 backuphash=8108 ...

Is this a good way to start this program?

Expand|Select|Wrap|Line Numbers
  1. for line in open('C:\Users\Admin\Desktop\podatki-picasa\.picasa.ini'):
  2.     if line.startswith('faces'):
  3.         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.
Nov 26 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 621
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.
Nov 29 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.