--
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.

--
You received this message because you are subscribed to the Google Groups "python-excel" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/python-excel/-/-QK0ilWQHw4J.
> I have one problem left.
> How can I make it so that the cells are written two, without me specifying
> manually what rows and columns to use?
Untested:
import xlrd
import xlwt
import sys
obook = xlwt.Workbook() # don't need encoding="utf-8"
# Your code won't work -- you use "book" for both input and output.
sheet1 = obook.add_sheet("ERRORSHEET")
sheet1.write(0, 0, "LANGUAGE")
sheet1.write(0, 1, "Double Spaces")
sheet1.write(0, 2, "Corrupted Characters")
sheet1.write(0, 3, "Unexpected Duplicate translation")
# get filenames from the command line
for outrowx, filename in enumerate(sys.argv[1:], 1):
book = xlrd.open_workbook(filename)
values = []
for sheet in book.sheets():
for rowx in xrange(sheet.nrows):
values.extend(sheet.row_values(rowx))
doublespaces = values.count('Consecutive spaces')
corruptedchar = values.count('Corrupt character')
unexpected = values.count('Unexpected # translations')
lang = filename
for colx, value in enumerate((lang, doublespaces - 1, corruptedchar -
1, unexpected - 1)):
sheet1.write(outrowx, colx, value)
obook.save("errors.xls")
I am having a hard time understanding some of what you did there. It's completely my fault. I wanted to get this finished and go over the code and understand what exactly I had done.
li = ['a', 'b', 'e']
I understand that what I am doing here is looping through the list. And then assigning 's' to each value in this list, and then printing each value.
But beyond this, I have no idea how for loops work. Particularly, when I come across something like this:
--
You received this message because you are subscribed to the Google Groups "python-excel" group.
It is hard for me to believe you have read countless *Python*
tutorials if you are confused by for loops and range. You said
earlier that Python is the first programming language you "can
somewhat comprehend" so I get that you're not a programmer.
The questions you are asking here are very basic, fundamental Python
questions and belong on a list or forum for Python beginners or
programming beginners, not on a list specifically for working with
Excel using Python.
I recommend reading through the official Python tutorial, which is
part of the standard documentation at www.python.org (or, if you are
using Windows, the same material is already on your computer,
reachable from the Start menu, listed as "Python Manuals" in the same
place that you would invoke the Python command-line or GUI).
If that tutorial is too advanced and programmer-oriented for you, I
recommend joining the python-tutor mailing list:
http://mail.python.org/mailman/listinfo/tutor
There you will find lots of helpful, patient Python programmers who
are accustomed to and willing to explain things to beginners.
Also check out
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
(That last link is also mentioned in the python-tutor info page.)
Good luck!
John Y.
--