Issue with writelines

S.Selvam s.selvamsiva at gmail.com
Wed Sep 2 19:40:46 CEST 2009


On Wed, Sep 2, 2009 at 6:50 PM, LeeRisq <leerisq at gmail.com> wrote:

> I've written this program that has been working fine until today.
> Can't work out why it stopped working. The program pulls a list from
> an xls file, inserts each item from the list into a repeating string,
> that then concatenates the repeating string and writes it to a text
> file. It has worked fine until today, and now for some reason, it
> stops after 30 items in my list. I also just tried another list, and
> that one stopped after 70 items. Perhaps someone could take a look?
>
> Here's the file followed by the traceback:
>
> import xlrd
> import win32clipboard
>
>
>
> def program_uno():
>    ofile = open(r"C:\Query\DQLVault.txt", "w")
>    book = xlrd.open_workbook(r"C:\DocLoader\MCL_Drawing and Legacy
> Docloader Sheet.xls")
>    sh = book.sheet_by_index(0)
>    e = sh.cell_value(1, 0)
>    a = sh.col_values(0, start_rowx=2, end_rowx=200)
>    b = r'%' + e
>    c = r'%Master-V%'
>    y = r"SELECT object_name, bp_master_date, revision,
> bp_revision_date, bp_unit_no, r_version_label, r_object_id,
> r_lock_owner, r_content_size, a_content_type, r_modify_date,
> r_object_type, r_link_cnt, r_assembled_from_id, r_has_frzn_assembly,
> a_is_hidden, i_is_replica, i_is_reference, r_is_virtual_doc,
> i_chronicle_id, i_folder_id FROM mcl_engineer (ALL) WHERE (((upper
> (object_name) like upper('%s')) and (any upper(r_version_label) like
> upper('%s'))" %(b, c)
>
>    w = r")) ORDER BY object_name ASC, r_object_id DESC, i_position
> DESC"
>
>    ofile.writelines(y)
>    for x in a:
>        d = r'%' + x
>        z = r" or (upper(object_name) like upper('%s')) and (any upper
> (r_version_label) like upper('%s'))" %(d, c)
>        f = ofile.writelines(z)
>    ofile.writelines(w)
>
>
> def copy_text():
>    ifile = open(r"C:\Query\DQLVault.txt", "r")
>    text = ifile.read()
>    ifile.close()
>
>    win32clipboard.OpenClipboard()
>    win32clipboard.EmptyClipboard()
>    win32clipboard.SetClipboardText(text)
>    win32clipboard.CloseClipboard()
>
> program_uno()
> copy_text()
>
> Traceback:
>
>  File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework
> \scriptutils.py", line 310, in RunScript
>    exec codeObject in __main__.__dict__
>  File "C:\Query\DQL Vault Revision Check.py", line 34, in <module>
>    program_uno()
>  File "C:\Query\DQL Vault Revision Check.py", line 20, in program_uno
>    f = ofile.writelines(z)
> TypeError: writelines() argument must be a sequence of strings
>

why can't you print/analyse the 'z ' value on except block.


>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Yours,
S.Selvam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090902/8fcba41f/attachment.html>


More information about the Python-list mailing list