On 14Jan2019 09:29, mhysnm1...@gmail.com <mhysnm1...@gmail.com> wrote:
Once again thanks for all the suggestions. It was the input data after
all. As I am importing three sheets into python. One of the sheets had
one less column.
Semantic nit: "fewer". "less" is for continuous values.
I've had to deal with loosely defined spreadsheets in the past year, and
ended up with some mapping classes for reading "heading based" CSV and
Excel sheets, where the first column contains column headings. It reads
the rows and constructs a namedtuple class for the rows with field names
based on the headings and then fills in the fields for each subsequent
row.
The advantage here is that then you can access the column data by name,
eg:
row.description
provided the column heading remains the same. See the xl_import function
from the cs.csvutils module:
https://pypi.org/project/cs.csvutils/
The code is here:
https://bitbucket.org/cameron_simpson/css/src/tip/lib/python/cs/csvutils.py
Right at the bottom of that file is an example use of xl_import() for a
worksheet where row 1 is a title and the column names are in row 2.
On and forward to start working on text pattern exercise which I always
have struggled with. Last language I did this in was Perl and had all
sorts of headaches. 😊 Python seems cleaner from the reading I have
done thus far. Lets see what challenges wait in front of me.
I used to use Perl extensively. I put off moving to Python for too long.
Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor