How do I process this?

Igor Korot ikorot01 at gmail.com
Tue Mar 4 05:03:46 CET 2014


Hi, ALL,
I have a csv file which depending on how it was produced gives 2 different
strings as shown in the example below (test1 and test2).
I am only interested in the first field in test1 and obviously in the whole
string of test2.

So, I tried to see if I can get what I want in one simple way, but failed.
Is it possible to process the file independently?

Thank you.

python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> test1 = "a,,,,"
>>> test2 = "a"
>>> (t1,_) = test1.split(',')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
>>> (t2,_) = test2.split(',')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: need more than 1 value to unpack
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140303/d9904ab4/attachment.html>


More information about the Python-list mailing list