Removing points from slow riders I have a CSV like the following.
Category,Position,Name,Time,Team,avg_power,20minWKG,Male?,20minpower
A,1,Tom Smith ,00:41:58.95,7605,295,4.4,1,299.2
A,2,James Johnson,00:41:58.99,2740,281,4.5,1,283.95
A,3,Tom Lamb,00:41:59.25,1634,311,4.2,1,315
B,1,Elliot Farmer,00:45:06.23,7562,306,3.9,1,312
B,2,Matt Jones,00:45:10.10,4400,292,4.0,1,300
B,3,Patrick James,00:45:39.83,6508,299,4.1,1,311.6

I get the time of the rider in first place of category 'A'.
I then give any rider that is 15% slower than this 0 points in a new CSV.
For example if the first rider take 1 minute 40 seconds, then anyone slower than 1 minute 55 seconds will get 0 points.
def convert(seconds):  # function to convert amount of seconds to a time format
    seconds = seconds % (24 * 3600)
    hour = seconds // 3600
    seconds %= 3600
    minutes = seconds // 60
    seconds %= 60
    return &quot;%d:%02d:%02d&quot; % (hour, minutes, seconds)


with open(&quot;results.csv&quot;, 'rt', encoding='UTF-8', errors='ignore') as file:  # opening the full results file
    reader = csv.reader(file, skipinitialspace=True, escapechar='\\')  # skipping headers
    MaleCategoryList = []  # setting category as blank so a change is recognised
    for row in reader:
             if row[0] not in MaleCategoryList:
                    if row[0] == &quot;A&quot;:
                        firstPlaceTime = datetime.strptime(row[3], &quot;%H:%M:%S.%f&quot;)
                        timeInSecs = firstPlaceTime.second + firstPlaceTime.minute * 60 + firstPlaceTime.hour * 3600
                        timeDifference = timeInSecs * 1.15
                        MaxTime = datetime.strptime(convert(timeDifference), &quot;%H:%M:%S&quot;)
# some code here which is not relevant i.e calculate points
             if cat == &quot;A&quot; and datetime.strptime(row[3], &quot;%H:%M:%S.%f&quot;) &gt; MaxTime:
                    points = int(0)
                    position_for_file = &quot;DQ Time-Cut&quot;
                    cat = &quot;Time Cut&quot;
             data = {'Position': position_for_file, 'Category': cat, 'Name': name, 'Club': club,
                        'Points': points, 'Time': time}  # dictionary of data to write to CSV

I feel that my code is very messy and inefficient. This is as there are lots of if in my loop and I believe a lot of the calculations seem unnecessary. Do you have any ideas of how I could improve my code?
I would prefer to not use Pandas if possible. This is as I have never used. However if there is a fast and easily maintainable solution to this with Pandas then I would be interested.
Time calculation
timeInSecs = firstPlaceTime.second + firstPlaceTime.minute * 60 + firstPlaceTime.hour * 3600

The first thing to do is attempt to get this as a timespan and avoid your own time math. In other words,
from datetime import datetime, time, timedelta

MIDNIGHT = time()

# ...

first_place_time = datetime.strptime(row[3], &quot;%H:%M:%S.%f&quot;)
time_span = first_place_time - datetime.combine(first_place_time, MIDNIGHT)
time_difference = time_span.total_seconds() * 1.15

Unpacking
You can unpack your row and avoid row[0], etc. fixed indexing, like:
category, position, name, race_time = row[:4]

Call reuse
This is written twice:
datetime.strptime(row[3], &quot;%H:%M:%S.%f&quot;)

so store it to a temporary variable.
PEP8
MaleCategoryList should be male_category_list, and MaxTime should be max_time.
Convert
Given the above code, you can get rid of most of convert. You should not put the time through another round-trip using a string.