DAY 38 — 60 DAY PYTHON CHALLENGE
CSV Reader
Python mein CSV Reader banao — Hindi mein step by step
Advertisement
Project kya hai?
Day 38 ka project hai CSV Reader!
Yeh project banane se aap Python ke important concepts
practice kar payenge. Neeche complete code hai — copy karo aur chalao!
Complete Python Code
python — csv_reader.py
# CSV Reader - Manual data se
data = [
["Naam", "Umar", "Shahar", "Score", "Grade"],
["Rahul", "20", "Mumbai", "85", "B"],
["Priya", "22", "Delhi", "92", "A"],
["Amit", "19", "Pune", "78", "C"],
["Sneha", "21", "Chennai", "88", "B"],
["Ravi", "23", "Bangalore","95", "A+"],
]
headers = data[0]
rows = data[1:]
print("=== CSV Reader ===")
print(f"Total records: {len(rows)}")
print()
# Table print karo
col_width = 12
print(" | ".join(f"{h:{col_width}}" for h in headers))
print("-" * (col_width * len(headers) + 3 * (len(headers)-1)))
for row in rows:
print(" | ".join(f"{c:{col_width}}" for c in row))
# Statistics
scores = [int(r[3]) for r in rows]
print(f"\n=== Statistics ===")
print(f" Total students : {len(rows)}")
print(f" Average score : {sum(scores)/len(scores):.1f}")
print(f" Highest score : {max(scores)}")
print(f" Lowest score : {min(scores)}")
# Filter - 90+ scorers
print("\n90+ scorers:")
for r in rows:
if int(r[3]) >= 90:
print(f" {r[0]} - {r[3]} ({r[4]})")
# Search by city
city = input("\nKis shahar ke students dekhen: ")
found = [r for r in rows if r[2].lower() == city.lower()]
print(f"\n{city} ke students: {len(found)}")
for r in found:
print(f" {r[0]} - Score: {r[3]}")
OUTPUT
=== CSV Reader === Total records: 5 Naam | Umar | Shahar | Score | Grade -------------------------------------------------------------------- Rahul | 20 | Mumbai | 85 | B Priya | 22 | Delhi | 92 | A === Statistics === Average score : 87.6 Highest score : 95 90+ scorers: Priya - 92 (A) Ravi - 95 (A+)
Code kaise kaam karta hai?
2D list se CSV data represent hota hai. List comprehension se scores extract hote hain aur filter bhi hota hai. Real CSV reader isi logic se kaam karta hai.
Advertisement
📋 Project ka Introduction
CSV Reader Python ka Day 38 ka project hai. Is project mein aap Python ke important concepts practice karenge jo real-world applications mein bahut use hote hain.
Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.
Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!
Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.
Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!
🧠 Is Project mein kya seekhoge?
Yeh project banate waqt aap ye Python concepts use karoge:
| Concept | Kya karta hai |
|---|---|
Variables | Data store karna |
Functions | Reusable code blocks |
Loops | Repeat karna |
Conditions | Decisions lena |
Input/Output | User se interact karna |
📝 Code kaise kaam karta hai — Step by Step
Neeche code ki poori logic step-by-step samjhayi gayi hai:
- Problem samjho: CSV Reader mein kya karna hai
- Required variables aur data structures decide karo
- Logic step-by-step likhó
- Code mein implement karo
- Test karo aur bugs fix karo
⚠️ Common Mistakes — Bhool mat jaana!
Beginners yeh galtiyan aksar karte hain — dhyan rakho:
- ⚠️ Indentation sahi rakho — Python mein spaces matter karti hain
- ⚠️ Variables ko use se pehle define karo
- ⚠️ Input ko int()/float() mein convert karo agar number chahiye
- ⚠️ Edge cases handle karo — kya hoga agar user galat input de?
🏋️ Practice Exercises — Aage badho!
Yeh project complete karne ke baad in exercises se practice karo:
- 💡 CSV Reader mein naya feature add karo
- 💡 Code ko functions mein refactor karo
- 💡 Error handling improve karo
- 💡 File mein data save karo
❓ Aksar Pooche Jane Wale Sawal (FAQ)
Q: CSV Reader project kyon banana chahiye?
A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
Q: Code run nahi ho raha?
A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
Q: Kaise improve karein?
A: Pehle basic version complete karo, phir ek ek feature add karte jao.
A: Pehle basic version complete karo, phir ek ek feature add karte jao.