mirror of
https://github.com/krishnadey30/LeetCode-Questions-CompanyWise.git
synced 2025-12-28 05:34:42 +00:00
## Description
- Add headers to all the CSV files
## Script used
```py
import csv
import os
# Set the path of the folder containing the CSV files
folder_path = "./LeetCode-Questions-CompanyWise"
headers = [
"ID",
"Title",
"Acceptance",
"Difficulty",
"Frequency",
"Leetcode Question Link",
]
# Loop through all the CSV files in the folder
for file_name in os.listdir(folder_path):
if file_name.endswith(".csv"):
# Read the CSV file into a list of rows
file_path = os.path.join(folder_path, file_name)
with open(file_path, "r") as f:
reader = csv.reader(f)
rows = list(reader)
has_headers = False
if len(rows) > 0 and rows[0] == headers:
has_headers = True
if not has_headers:
rows.insert(0, headers)
# Write the list of rows back to the CSV file
with open(file_path, "w", newline="") as f:
writer = csv.writer(f)
writer.writerows(rows)
```
1.6 KiB
1.6 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 759 | Employee Free Time | 66.3% | Hard | 0.8067517126995383 | https://leetcode.com/problems/employee-free-time |
| 3 | 695 | Max Area of Island | 62.7% | Medium | 0.7079785078050851 | https://leetcode.com/problems/max-area-of-island |
| 4 | 1229 | Meeting Scheduler | 52.7% | Medium | 0.5152176154540078 | https://leetcode.com/problems/meeting-scheduler |
| 5 | 1359 | Count All Valid Pickup and Delivery Options | 57.9% | Hard | 0.4639892692240469 | https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options |
| 6 | 355 | Design Twitter | 30.3% | Medium | 0.3183174263408411 | https://leetcode.com/problems/design-twitter |
| 7 | 1174 | Immediate Food Delivery II | 58.5% | Medium | 0.12555653398976382 | https://leetcode.com/problems/immediate-food-delivery-ii |
| 8 | 1173 | Immediate Food Delivery I | 80.4% | Easy | 0.06592172080482424 | https://leetcode.com/problems/immediate-food-delivery-i |
| 9 | 37 | Sudoku Solver | 43.6% | Hard | 0.01821543989134118 | https://leetcode.com/problems/sudoku-solver |
| 10 | 210 | Course Schedule II | 40.7% | Medium | 0.01704828902223426 | https://leetcode.com/problems/course-schedule-ii |
| 11 | 56 | Merge Intervals | 39.3% | Medium | 0.013819532422258866 | https://leetcode.com/problems/merge-intervals |
| 12 | 227 | Basic Calculator II | 36.9% | Medium | 0.01239941490503826 | https://leetcode.com/problems/basic-calculator-ii |
| 13 | 36 | Valid Sudoku | 48.7% | Medium | 0.007258242715805398 | https://leetcode.com/problems/valid-sudoku |
| 14 | 15 | 3Sum | 26.8% | Medium | 0.004940992758742591 | https://leetcode.com/problems/3sum |
| 15 | 121 | Best Time to Buy and Sell Stock | 50.5% | Easy | 0.0047725193990346675 | https://leetcode.com/problems/best-time-to-buy-and-sell-stock |
| 16 | 146 | LRU Cache | 33.2% | Medium | 0.004600353139061353 | https://leetcode.com/problems/lru-cache |