import csv
def count_records(csv_file):
record_count = 0
first_line = None
last_line = None
# Open the CSV file and read it line by line
with open(csv_file, 'r', newline='') as file:
reader = csv.reader(file)
try:
first_line = next(reader)
for row in reader:
last_line = row
record_count += 1
except StopIteration:
pass
return record_count, first_line, last_line
# Specify the path to your CSV file
csv_file_path = 'path/to/your/file.csv'
# Count the records, get the first and last lines
num_records, first_row, last_row = count_records(csv_file_path)
# Display the results
print(f"Number of records in the CSV file: {num_records}")
print("First line:", first_row)
print("Last line:", last_row)
Bugs are happily living there and they always will, unless Computers begin to develop IQ
Thursday, October 12, 2023
Read CSV from S3
Subscribe to:
Posts (Atom)
Read CSV from S3
import csv def count_records(csv_file): record_count = 0 first_line = None last_line = None # Open the CSV file and read it...
-
Super explanation of Stale element exception and how to handle QA & Testing: StaleElementException
-
Check out Level 1 - Foundation Training MCQs Provide you feedback under comment section - 1. Machine Templates only work for: Activ...
-
Here are the collection of UiPath MCQ question helpful in certification in UiPath RPA and interview. Check out Level 2 - Orchestrato...