Author: Pinaka
This project is a CLI-based CSV Analytics Tool that allows users to:
- 📂 Select a CSV file
- 📊 View metadata (rows, columns)
- 🔍 Sort data by a selected column
- 💾 Save filtered results
- 🎨 View everything beautifully using
rich
It combines:
csv→ CSV parsingtkinter→ File selection dialogrich→ Styled CLI outputDictReader→ Dictionary-based row access
This is a real-world beginner data analysis tool.
- Reading CSV files properly
- Working with structured tabular data
- Sorting dictionaries
- Handling user input safely
- CLI UI styling
- Saving processed data
- Mini data pipeline thinking
1. User selects CSV file
2. Load file into memory
3. Show summary (rows + columns)
4. Ask which column to sort
5. Ask ascending/descending
6. Sort data
7. Display table
8. Ask if user wants to save
9. Save filtered data
Simple. Clean. Practical.
pip install richNo need to install tkinter (comes pre-installed with Python in most systems).
reader = csv.DictReader(f)This converts:
name,age,city
John,25,Delhi
Into:
{
"name": "John",
"age": "25",
"city": "Delhi"
}Each row becomes a dictionary.
✔ Clean ✔ Flexible ✔ Easy column access
data_count = len(rows)
column_count = len(headers)Gives:
- Total rows
- Total columns
- Column names
sorted(rows, key=lambda x: x[column])This sorts rows based on selected column.
⚠ Important:
Right now sorting is string-based.
If numbers exist:
1, 10, 2
It sorts like:
1, 10, 2
Not numerically.
For numeric sorting:
key=lambda x: float(x[column]) if x[column].replace('.', '', 1).isdigit() else x[column]This makes sorting smarter.
table = Table(
title=title,
show_lines=True,
box=box.SIMPLE_HEAVY
)This makes your CLI look professional.
Each column:
table.add_column(header, style="cyan")Each row:
table.add_row(*(str(row[h]) for h in headers))Beautiful output. No manual formatting needed.
Uses:
csv.DictWriterPreserves structure and headers.
Automatically creates:
filtered_data.csv
inside selected folder.
Try modifying this tool to:
Add feature:
- Show rows where
city == Delhi
After sorting:
filtered_data = filtered_data[:5]Add:
- Min value
- Max value
- Average
For numeric columns.
Sort by:
- age
- then name
Ask user:
Enter keyword:
Return rows containing that word.
This logic applies to:
- Sales reports
- Student marksheets
- Expense tracking
- Log filtering
- Stock price CSV
- Survey results
- HR records
This is how basic data tools are built.
- Loads entire file into memory
- No numeric detection
- No filtering condition (only sorting)
- No large file optimization
But for beginner → intermediate level, this is excellent.
| Skill | Level |
|---|---|
| CSV Parsing | Beginner+ |
| Sorting | Intermediate |
| CLI Styling | Intermediate |
| Data Handling | Intermediate |
| Real-World Thinking | Advanced Beginner |
Ask yourself:
- What is the structure of CSV internally?
- Why use DictReader over reader?
- Why convert everything to string before printing?
- What happens if column doesn’t exist?
- What if file is empty?
- What if column contains mixed data types?
These are real engineer questions.