How to read an Excel CSV file in Python

0 votes
data = ['a', 'b', 'c', 'd', 'c', 'd', 'c', 'd']

pattern_counts = {}

for i in range(len(data)-2):
    pattern = str(data[i]) + str(data[i+1]) + str(data[i+2])
    if pattern in pattern_counts:
        pattern_counts[pattern] += 1
    else:
        pattern_counts[pattern] = 1

for pattern, count in pattern_counts.items():
    print("{}: {}".format(pattern, count))

When this code executes, a list of patterns for three value sets is printed. It accomplishes this effectively and precisely.

I want to know how to get it to read an Excel CSV file with vertical values going down.

I've attempted and will continue to try breaking down the code to figure out how to translate it into reading cells.

Mar 19, 2023 in Others by narikkadan
• 86,360 points
1,225 views