csv blank fields

Mag Gam magawake at gmail.com
Sat Jun 27 12:35:47 EDT 2009


Peter:

Sorry if I wasn't clear before.

While reading my csv file, notice I am putting the content in an array.

If lets say, row[5] has nothing in it, python gives an exception.
Instead of the exception, I would like to assign 'NULL' to row[5].

Does that help?


On Sat, Jun 27, 2009 at 10:03 AM, Peter Otten<__peter__ at web.de> wrote:
> Mag Gam wrote:
>
>> well, I am actually loading the row into a fixed width array
>>
>> reader=csv.reader(fs)
>> for s,row in enumerate(reader):
>>
> t=np.array([(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10])],dtype=mtype)
>>   d[s]=t
>>
>>
>> If there is a missing field, I get a problem in one of my rows
>
> Please be specific. Describe what you want and what you get.
>
> If you give code make it self-contained so that others can run it without
> having to guess the values of the variables you introduce.
>
> If an exception occurs cut and paste the traceback into your post, too.
>
> Peter
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list