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 | 236 | Lowest Common Ancestor of a Binary Tree | 45.7% | Medium | 0.06122838444838759 | https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree |
| 3 | 437 | Path Sum III | 47.2% | Medium | 0.04550116684579005 | https://leetcode.com/problems/path-sum-iii |
| 4 | 443 | String Compression | 41.3% | Easy | 0.029773949243192512 | https://leetcode.com/problems/string-compression |
| 5 | 981 | Time Based Key-Value Store | 53.1% | Medium | 0.02132276946882123 | https://leetcode.com/problems/time-based-key-value-store |
| 6 | 146 | LRU Cache | 33.2% | Medium | 0.017369086240613615 | https://leetcode.com/problems/lru-cache |
| 7 | 127 | Word Ladder | 29.6% | Medium | 0.012849976929025548 | https://leetcode.com/problems/word-ladder |
| 8 | 273 | Integer to English Words | 27.1% | Hard | 0.01153415324528653 | https://leetcode.com/problems/integer-to-english-words |
| 9 | 387 | First Unique Character in a String | 53.4% | Easy | 0.008959741371471904 | https://leetcode.com/problems/first-unique-character-in-a-string |
| 10 | 20 | Valid Parentheses | 39.0% | Easy | 0.004938010692392608 | https://leetcode.com/problems/valid-parentheses |
| 11 | 139 | Word Break | 40.1% | Medium | 0.003755167762323698 | https://leetcode.com/problems/word-break |
| 12 | 283 | Move Zeroes | 57.8% | Easy | 0.002758622439079723 | https://leetcode.com/problems/move-zeroes |
| 13 | 53 | Maximum Subarray | 46.5% | Easy | 0.0020745819379855658 | https://leetcode.com/problems/maximum-subarray |
| 14 | 121 | Best Time to Buy and Sell Stock | 50.5% | Easy | 0.0020383211296970956 | https://leetcode.com/problems/best-time-to-buy-and-sell-stock |
| 15 | 3 | Longest Substring Without Repeating Characters | 30.4% | Medium | 0.0014852223137141987 | https://leetcode.com/problems/longest-substring-without-repeating-characters |