colinfo_map[colindex] missing

118 views
Skip to first unread message

Ervin Hegedüs

unread,
Sep 22, 2010, 5:19:26 PM9/22/10
to python...@googlegroups.com
Hello,

I've attached an xls file (colinfo_test.xls), and a simple test file
(colinfo_test.py) to py-excel Google groups
(http://groups.google.com/group/python-excel/files).

From that xls file xlrd can't read colinfo_map[4] - what's the problem?
(I have tested with xlrd 0.7.2a2, checked out from SVN)

Thank you:


a.

John Machin

unread,
Sep 22, 2010, 6:49:38 PM9/22/10
to python...@googlegroups.com


The file has no COLINFO record covering that column.

Note that the docs

https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html#sheet.Sheet.colinfo_map-attribute

say "there may be no entry for unused columns". Perhaps this needs to be
augmented with "or columns with only default formatting" -- I note that
in sheet 0 of your file, column E (column index == 4) appears to have
the default width, and columns A-D and F appear to have been dragged to
a non-default width.

Ervin Hegedüs

unread,
Sep 23, 2010, 5:08:22 AM9/23/10
to python...@googlegroups.com
Hello John,

thanks for the reply,

> The file has no COLINFO record covering that column.

yes, I have tried to debug the runs of script, and it seems there is no COLINFO,

> Note that the docs
>
> https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html#sheet.Sheet.colinfo_map-attribute
>
> say "there may be no entry for unused columns". Perhaps this needs to be
> augmented with "or columns with only default formatting" -- I note that in
> sheet 0 of your file, column E (column index == 4) appears to have the
> default width, and columns A-D and F appear to have been dragged to a
> non-default width.

ok, after I understanded ther is no COLINFO, I started to read the doc:
https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html#sheet.Colinfo-class

In BIFF8, if a COLINFO record is missing for a column, the width
specified in the record STANDARDWIDTH is used. If this [STANDARDWIDTH]
record is also missing, the column width of the record DEFCOLWIDTH is
used instead."""

But there is no default value.

I forgot something?


Thanks:


a.

> --
> You received this message because you are subscribed to the Google Groups
> "python-excel" group.
> To post to this group, send an email to python...@googlegroups.com.
> To unsubscribe from this group, send email to
> python-excel...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/python-excel?hl=en-GB.
>
>

John Machin

unread,
Sep 23, 2010, 6:34:31 AM9/23/10
to python...@googlegroups.com
On 23/09/2010 7:08 PM, Ervin Heged�s wrote:
> Hello John,
>
> thanks for the reply,
>
>> The file has no COLINFO record covering that column.
>
> yes, I have tried to debug the runs of script, and it seems there is no COLINFO,
>
>> Note that the docs
>>
>> https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html#sheet.Sheet.colinfo_map-attribute
>>
>> say "there may be no entry for unused columns". Perhaps this needs to be
>> augmented with "or columns with only default formatting" -- I note that in
>> sheet 0 of your file, column E (column index == 4) appears to have the
>> default width, and columns A-D and F appear to have been dragged to a
>> non-default width.
>
> ok, after I understanded ther is no COLINFO, I started to read the doc:
> https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html#sheet.Colinfo-class
>
> In BIFF8, if a COLINFO record is missing for a column, the width
> specified in the record STANDARDWIDTH is used. If this [STANDARDWIDTH]
> record is also missing, the column width of the record DEFCOLWIDTH is
> used instead."""
>
> But there is no default value.

I don't understand what you mean:

>>> import xlrd
>>> b = xlrd.open_workbook("colinfo_test.xls", formatting_info=1)
>>> s = b.sheet_by_index(0)
>>> s.standardwidth
>>> s.defcolwidth
8


Ervin Hegedüs

unread,
Sep 23, 2010, 7:00:14 AM9/23/10
to python...@googlegroups.com
Hello John,

thanks again,

>> In BIFF8, if a COLINFO record is missing for a column, the width
>> specified in the record STANDARDWIDTH is used. If this [STANDARDWIDTH]
>> record is also missing, the column width of the record DEFCOLWIDTH is
>> used instead."""
>>
>> But there is no default value.
>
> I don't understand what you mean:
>
>   >>> import xlrd
>   >>> b = xlrd.open_workbook("colinfo_test.xls", formatting_info=1)
>   >>> s = b.sheet_by_index(0)
>   >>> s.standardwidth
>   >>> s.defcolwidth
>   8

ok,

I belived if there is no COLINFO, xlrd inserts it as implicit to
colinfo_map. These are not Colinfo objects - it's not problem, I just
indicating.

So, I see there is pre-defined value, what I can use, and I can handle
the missing of COLINFO object of that cell.

(Would be right to insert it as implicit mode to colinfo_map?)


Thank you for your help:


a.

John Machin

unread,
Sep 23, 2010, 7:27:25 AM9/23/10
to python...@googlegroups.com
On 23/09/2010 9:00 PM, Ervin Heged�s wrote:
> Hello John,
>
> thanks again,
>
>>> In BIFF8, if a COLINFO record is missing for a column, the width
>>> specified in the record STANDARDWIDTH is used. If this [STANDARDWIDTH]
>>> record is also missing, the column width of the record DEFCOLWIDTH is
>>> used instead."""
>>>
>>> But there is no default value.
>>
>> I don't understand what you mean:
>>
>> >>> import xlrd
>> >>> b = xlrd.open_workbook("colinfo_test.xls", formatting_info=1)
>> >>> s = b.sheet_by_index(0)
>> >>> s.standardwidth
>> >>> s.defcolwidth
>> 8
>
> ok,
>
> I belived if there is no COLINFO, xlrd inserts it as implicit to
> colinfo_map. These are not Colinfo objects - it's not problem, I just
> indicating.

Hint: if xlrd did that, the data structure would be named colinfo_list :-)

> So, I see there is pre-defined value, what I can use, and I can handle
> the missing of COLINFO object of that cell.
>
> (Would be right to insert it as implicit mode to colinfo_map?)

I'd prefer not to.

> Thank you for your help:

You're welcome.

Cheers,
John

Ervin Hegedüs

unread,
Sep 23, 2010, 7:52:56 AM9/23/10
to python...@googlegroups.com
Hello John,


>> I belived if there is no COLINFO, xlrd inserts it as implicit to
>> colinfo_map. These are not Colinfo objects - it's not problem, I just
>> indicating.
>
> Hint: if xlrd did that, the data structure would be named colinfo_list :-)

I mean if sheet has N column, but colinfo_map.keys() doesn't contain
all index in range(N), then sheet object implicit creates them with
default values, eg. colinfo.width will be 8.


>> (Would be right to insert it as implicit mode to colinfo_map?)
>
> I'd prefer not to.

May I ask it why? (Just may be I forgot something... I'd like to see clearly)


thank you:


a.

John Machin

unread,
Sep 23, 2010, 9:50:39 AM9/23/10
to python...@googlegroups.com
On 23/09/2010 9:52 PM, Ervin Heged�s wrote:
> Hello John,
>
>
>>> I belived if there is no COLINFO, xlrd inserts it as implicit to
>>> colinfo_map. These are not Colinfo objects - it's not problem, I just
>>> indicating.
>>
>> Hint: if xlrd did that, the data structure would be named colinfo_list :-)
>
> I mean if sheet has N column, but colinfo_map.keys() doesn't contain
> all index in range(N), then sheet object implicit creates them with
> default values, eg. colinfo.width will be 8.

I know what you mean. My point is that if that were done, then the final
structure would be better as a list. However, it is named colinfo_MAP,
not colinfo_LIST, which should have given you a clue that your belief
was ill-founded.

>>> (Would be right to insert it as implicit mode to colinfo_map?)
>>
>> I'd prefer not to.
>
> May I ask it why? (Just may be I forgot something... I'd like to see clearly)

Because I'd prefer you to use the existing Sheet.computed_column_width
method ... see
https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html#sheet.Sheet.computed_column_width-method


Ervin Hegedüs

unread,
Sep 23, 2010, 10:16:00 AM9/23/10
to python...@googlegroups.com
Hello John,

>> I mean if sheet has N column, but colinfo_map.keys() doesn't contain
>> all index in range(N), then sheet object implicit creates them with
>> default values, eg. colinfo.width will be 8.
>
> I know what you mean. My point is that if that were done, then the final
> structure would be better as a list.

No.
I mean colinfo structure stay as MAP, just if some column doesn't have
COLINFO, xlrd implicit creates one in colinfo_map, the key is column
index which doesn't has COLINFO. :)

> However, it is named colinfo_MAP, not
> colinfo_LIST, which should have given you a clue that your belief was
> ill-founded.

yes, I knew it.

>>> I'd prefer not to.
>>
>> May I ask it why? (Just may be I forgot something... I'd like to see
>> clearly)
>
> Because I'd prefer you to use the existing Sheet.computed_column_width
> method ... see
> https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html#sheet.Sheet.computed_column_width-method

that's what I'm looking for exactly :)

Thank you:


a.

Reply all
Reply to author
Forward
0 new messages