""" Toy program to open a file and print the first 10 lines. """ def get_date(line): return line.split(',')[1] n = 200000 filename = 'NIBRSPublicView2025.csv' count = {} # initialize a count object. # count['1/1/2025'] = 1 with open(filename, 'r') as f: # next(f) # This reads and discards the first line, the heading. f.readline() for i, line in enumerate(f): if i < n: print(f"[{i+1}] {line.strip()}") # .strip() removes leading/trailing whitespace, including newlines date = get_date(line) print(f"date: {date}") if date in count: # not the first occurence of date. count[date] += 1 print(f"{date}: {count[date]}") else: count[date] = 1 print(f"{date}: {count[date]}") else: break print("Houston crime incidences reported to FBI NIBRS in 2025") # Iterate through count and print the result. for date, value in count.items(): print(f"{date}: {value}")