I have a million rows and I need to find the max character length of a field. For example, the data might look like this:
[
['john doe', 12, 2.99],
['jane doe', 29, 3.99],
]
And to figure out the maxLength of the first column I would do:
maxLength = 0
for row in rows:
maxLength = max(len(row[0]), maxLength)
However, determining the len(str)
seems like an expensive operation. Is there a better way to do this, even perhaps approximating the max length, etc? An answer in python or C/C++ is fine -- I'm just looking for how it would be done.