A Simple ChatGPT Use Case
Don’t you hate data quality issues? I surely do.
I surpassed the halfway point of my 60-day fitness challenge, and I’ve tracked my daily stats at the bottom of my post.
While inputting today’s data, I realized I should verify that I have entered all my data correctly. The challenge began on 2025-05-19, so I should have had 35 days of data (including today). But I only had 34 records.
I forgot to log a day. But which one? Figuring it out was more complicated than it should have been.
My biggest mistake when I started tracking the data was not including a date column in my table. I had a day column, which stated which of the 60 days each row represented, but that gave no insight into which date the record landed on.
So, I had to manually review each one and use my superscript notes as a reference. I found that I forgot to log my stats from the previous Thursday. Since it was only a few days ago, I remembered my stats and could fix my data.
But I don’t want this same mistake to happen.
I decided to add a date column to my table to help me track my data more efficiently.
However, there was an issue…
I manually created the table within my CMS using raw HTML. So, adding a date column meant creating an additional <td>
tag in each <tr>
within my HTML.
Doing this for 35 records is not insane. However, I’m lazy and didn’t want to waste five minutes on the task, so I delegated it to ChatGPT.
I copied and pasted my HTML into the LLM, which looked something like this.
<table>
<thead>
<tr>
<th>Day #</th>
<th>Running Miles</th>
<th>Pull-ups</th>
<th>Pistol Squats (per leg)</th>
<th>Handstand Pushups</th>
<th>Pushups</th>
</tr>
</thead>
<tbody>
<tr>
<td>Day 1</td>
<td>1</td>
<td>25</td>
<td>15</td>
<td>15</td>
<td>100</td>
</tr>
<tr>
<td>Day 2</td>
<td>1</td>
<td>50</td>
<td>15</td>
<td>15</td>
<td>150</td>
</tr>
<!-- ...More rows... -->
<tr>
<td>Day 33</td>
<td>-</td>
<td>28</td>
<td>15</td>
<td>19</td>
<td>100</td>
</tr>
<tr>
<td>Day 34</td>
<td>1</td>
<td>26</td>
<td>15</td>
<td>16</td>
<td>100</td>
</tr>
</tbody>
</table>
I asked ChatGPT to add a date column to the table and make each row represent one plus the previous date, beginning with my challenge’s start date (2025-05-19).
Simple enough, right?
Wrong. The resulting HTML was too large for ChatGPT to output. Luckily, LLMs are becoming more advanced by the day and can offer alternative solutions. It said that it could, instead, write a Python script that could manipulate the HTML for me.
After some manual cleaning and spot checking, I ended up with this code.
from datetime import datetime, timedelta
# Define base HTML structure
header = """
<table>
<thead>
<tr>
<th>Day #</th>
<th>Date</th>
<th>Running Miles</th>
<th>Pull-ups</th>
<th>Pistol Squats (per leg)</th>
<th>Handstand Pushups</th>
<th>Pushups</th>
</tr>
</thead>
<tbody>
"""
rows = [
["Day 1", "1", "25", "15", "15", "100"],
["Day 2", "1", "50", "15", "15", "150"],
"""...More Rows..."""
["Day 34", "-", "28", "15", "19", "100"],
["Day 35", "1", "26", "15", "16", "100"]
]
start_date = datetime(2025, 5, 19)
rows_html = ""
for i, row in enumerate(rows):
date_str = (start_date + timedelta(days=i)).strftime("%Y-%m-%d")
row_html = f" <tr>\n <td>{row[0]}</td>\n <td>{date_str}</td>\n"
row_html += "".join([f" <td>{cell}</td>\n" for cell in row[1:]])
row_html += " </tr>\n"
rows_html += row_html
footer = """ </tbody>
</table>
"""
# Combine full HTML content
full_html = header + rows_html + footer
# Save to a file
file_path = "AddDatesTo60DayFitenssChallengeTable.html"
with open(file_path, "w") as f:
f.write(full_html)
I executed the code, and, like magic, I had my updated table with dates.
Gotta love LLMs.