>But I still don't know how to get the
>statistic result of each column,
try:
cols = len( text[0] ) # Find out how many columns there are (assuming each
row has the same number of columns)
except IndexError:
raise # This will make sure you can see the error while developing;
# replace with whatever is appropriate for your application
results = []
for idx in xrange( cols ):
results.append( 0 ) # Initialize an array to zero value with the correct
number of columns
# results = [ 0, 0, 0 ] for 3 columns
for line in text: # Check each row
for col_idx, field in enumerate( line ): # check each column
if token in field:
# Or possibly if token==field, not sure exactly what kind of
comparison you need.
results[col_idx] += 1 # token found so increment count for that
column
This is a simple to understand, brute-force solution. It is not very efficient
and might be slow for large amounts of data.
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor