One core habit
Treat files as the input layer of your tool. Read the file, convert it into Python data, then let the rest of your code work with lists and dictionaries.
Do not mix file reading, API calls, and output writing in one big block. Your future self will find bugs faster when each part has one job.
Why this matters
Your hackathon repo must prove that your script reads data. A sample input file is the easiest proof.
For an AI-adjacent tool, the input may be student feedback, product reviews, job descriptions, support tickets, or prompts. Keep a small sample in the repo so anyone can test it without asking you for data.
Pick file types
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 4 done
Read a text file
Use with open so Python closes the file properly. Use encoding="utf-8" so Indian names and symbols are handled better.
from pathlib import Path
input_path = Path("sample_input/feedback.txt")
with open(input_path, "r", encoding="utf-8") as file:
lines = file.readlines()
clean_lines = [line.strip() for line in lines if line.strip()]
print(clean_lines)Read JSON data
JSON maps cleanly to Python. JSON objects become dictionaries. JSON arrays become lists.
This is useful before you call a real API. You can first test your logic with a mock JSON file.
# sample_input/jobs.json
[
{
"title": "Python Intern",
"company": "Bengaluru SaaS Startup",
"skills": ["python", "apis", "sql"]
},
{
"title": "AI Tooling Intern",
"company": "Pune Product Team",
"skills": ["python", "json", "llm"]
}
]
# read_json.py
import json
from pathlib import Path
input_path = Path("sample_input/jobs.json")
with open(input_path, "r", encoding="utf-8") as file:
jobs = json.load(file)
for job in jobs:
print(job["title"], "-", ", ".join(job["skills"]))Read CSV rows
CSV is common because people export it from spreadsheets. Python has a built-in csv module, so you do not need pandas for small inputs.
# sample_input/reviews.csv
name,rating,comment
Asha,5,Fast delivery and good support
Rohan,2,App crashed during payment
# read_csv.py
import csv
from pathlib import Path
input_path = Path("sample_input/reviews.csv")
with open(input_path, "r", encoding="utf-8", newline="") as file:
reader = csv.DictReader(file)
reviews = list(reader)
for review in reviews:
print(review["name"], review["rating"], review["comment"])Common mistake
Do not hard-code your full laptop path, like C:\Users\you\Desktop\project\file.json. That will fail on your teammate’s laptop and on a judge’s machine.
Use relative paths from your project folder, like sample_input/jobs.json. Run the script from the repo root while testing.
Use AI carefully
You can ask ChatGPT or Gemini to generate a small sample JSON or CSV file for your tool. Ask for 5 to 10 fake rows only.
Check that the data has no real phone numbers, emails, API keys, private college records, or copied company data. Public repos need safe sample data.
Do this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done