On 04-May-11 11:40, Greg Christian wrote:
Python version = 2.7.1
Platform = win32
I am kind of stuck on what is probably a simple thing:
If we have a file of words like this:
“first”,”word”,”in”,”that”,”another”,”part”,”of”,”this”

It depends on exactly how "just like" that example the file is.
For example, if it's a comma-separated value (CSV) file, with values enclosed optionally in quotes (as shown in your example), you can very easily and yet robustly read it using the csv module in the standard library.

Otherwise you could use regular expressions to find text inside "" quotes and ignore the commas. Or split on ',' then strip quotes, or...

CSV is easiest if that's a match for your problem domain.

--
Steve Willoughby / st...@alchemy.com
"A ship in harbor is safe, but that is not what ships are built for."
PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to