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.4 KiB
1.4 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 25 | Reverse Nodes in k-Group | 42.1% | Hard | 0.05055437541222425 | https://leetcode.com/problems/reverse-nodes-in-k-group |
| 3 | 76 | Minimum Window Substring | 34.6% | Hard | 0.04336436867416216 | https://leetcode.com/problems/minimum-window-substring |
| 4 | 845 | Longest Mountain in Array | 37.2% | Medium | 0.03578987502740307 | https://leetcode.com/problems/longest-mountain-in-array |
| 5 | 269 | Alien Dictionary | 33.3% | Hard | 0.027110094009475887 | https://leetcode.com/problems/alien-dictionary |
| 6 | 166 | Fraction to Recurring Decimal | 21.6% | Medium | 0.019305618894153366 | https://leetcode.com/problems/fraction-to-recurring-decimal |
| 7 | 207 | Course Schedule | 43.1% | Medium | 0.010625837876226181 | https://leetcode.com/problems/course-schedule |
| 8 | 23 | Merge k Sorted Lists | 40.2% | Hard | 0.008699909875545938 | https://leetcode.com/problems/merge-k-sorted-lists |
| 9 | 127 | Word Ladder | 29.6% | Medium | 0.005731495844689608 | https://leetcode.com/problems/word-ladder |
| 10 | 56 | Merge Intervals | 39.3% | Medium | 0.0033129067901687907 | https://leetcode.com/problems/merge-intervals |
| 11 | 200 | Number of Islands | 46.8% | Medium | 0.002765297303115152 | https://leetcode.com/problems/number-of-islands |
| 12 | 283 | Move Zeroes | 57.8% | Easy | 0.002758622439079723 | https://leetcode.com/problems/move-zeroes |
| 13 | 26 | Remove Duplicates from Sorted Array | 45.1% | Easy | 0.0018681118827202508 | https://leetcode.com/problems/remove-duplicates-from-sorted-array |