Mag Gam wrote:
I am using the csv package to parse a compressed .csv.gz file. So far
its working perfectly fine but it fails when I have a missing value in
on of the fields.
For example, I have this
Abc,def,,jkl
Is it possible to fill the missing column with a null?
I want,
Abc,def,NULL,jkl
Thankyou!
On Tue, Jun 30, 2009 at 12:17 AM, Chris Rebert wrote:
> On Mon, Jun 29, 2009 at 8:47 PM, Lawrence
> D'Oliveiro wrote:
>> In message , MRAB
>> wrote:
>>
>>> row = [r or "NULL" for r in row]
>>
>> I know that, in this particular case, all the elements of row are strings,
>> and the
On Mon, Jun 29, 2009 at 8:47 PM, Lawrence
D'Oliveiro wrote:
> In message , MRAB
> wrote:
>
>> row = [r or "NULL" for r in row]
>
> I know that, in this particular case, all the elements of row are strings,
> and the only string that is equivalent to False is the empty string, but
> still
>
>
In message , MRAB
wrote:
> row = [r or "NULL" for r in row]
I know that, in this particular case, all the elements of row are strings,
and the only string that is equivalent to False is the empty string, but
still
row = [[r, "NULL"][r == ""] for r in row]
--
http://mail.python.org
Mag Gam wrote:
Please don't top-post.
> Sorry if I wasn't clear before.
>
> While reading my csv file, notice I am putting the content in an array.
That's already in the code you posted. What's missing is the value of
"mtypes". I really meant it when I asked you to provide a self-contained
ex
Mag Gam wrote:
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?
You still didn't
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,
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 i
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,
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
Mag Gam wrote:
I am using the csv package to parse a compressed .csv.gz file. So far
its working perfectly fine but it fails when I have a missing value in
on of the fields.
For example, I have this
Abc,def,,jkl
Is it possible to fill the missing column with a null?
I want,
Abc,def,NULL,jkl
I am using the csv package to parse a compressed .csv.gz file. So far
its working perfectly fine but it fails when I have a missing value in
on of the fields.
For example, I have this
Abc,def,,jkl
Is it possible to fill the missing column with a null?
I want,
Abc,def,NULL,jkl
TIA
--
http://ma
12 matches
Mail list logo