audiocaps icon indicating copy to clipboard operation
audiocaps copied to clipboard

Different number of examples in csv files?

Open Pompey21 opened this issue 1 year ago • 1 comments

my csv counter script has counted different number of examples so I corrected it :)

Pompey21 avatar Apr 23 '24 14:04 Pompey21

this is the csv counter script I used:

import csv

def count_lines_in_csv(file_path):
    try:
        with open(file_path, 'r') as csvfile:
            # Use csv.reader to iterate over the lines in the CSV file
            csv_reader = csv.reader(csvfile)
            # Use a counter to count the number of lines
            line_count = sum(1 for row in csv_reader)
        return line_count
    except FileNotFoundError:
        print("File not found.")
        return None
    except Exception as e:
        print("An error occurred:", e)
        return None

# Example usage:
file_path = 'val.csv'  # Replace 'example.csv' with the path to your CSV file
line_count = count_lines_in_csv(file_path)
if line_count is not None:
    print("Number of lines in the CSV file:", line_count)

Pompey21 avatar Apr 23 '24 14:04 Pompey21