mirror of
https://github.com/McSmog/LeetCode-Questions-CompanyWise.git
synced 2026-04-19 16:56:45 +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.7 KiB
1.7 KiB
| 1 | ID | Title | Acceptance | Difficulty | Frequency | Leetcode Question Link |
|---|---|---|---|---|---|---|
| 2 | 592 | Fraction Addition and Subtraction | 49.0% | Medium | 1.0862508215008657 | https://leetcode.com/problems/fraction-addition-and-subtraction |
| 3 | 691 | Stickers to Spell Word | 42.9% | Hard | 0.6866391392689652 | https://leetcode.com/problems/stickers-to-spell-word |
| 4 | 166 | Fraction to Recurring Decimal | 21.6% | Medium | 0.6608271814955181 | https://leetcode.com/problems/fraction-to-recurring-decimal |
| 5 | 945 | Minimum Increment to Make Array Unique | 46.3% | Medium | 0.26121549926361765 | https://leetcode.com/problems/minimum-increment-to-make-array-unique |
| 6 | 697 | Degree of an Array | 53.8% | Easy | 0.11752319415823444 | https://leetcode.com/problems/degree-of-an-array |
| 7 | 234 | Palindrome Linked List | 39.3% | Easy | 0.1029927766102897 | https://leetcode.com/problems/palindrome-linked-list |
| 8 | 598 | Range Addition II | 49.6% | Easy | 0.09763846956391599 | https://leetcode.com/problems/range-addition-ii |
| 9 | 23 | Merge k Sorted Lists | 40.2% | Hard | 0.0464758840344532 | https://leetcode.com/problems/merge-k-sorted-lists |
| 10 | 717 | 1-bit and 2-bit Characters | 48.8% | Easy | 0.024346911678336462 | https://leetcode.com/problems/1-bit-and-2-bit-characters |
| 11 | 162 | Find Peak Element | 43.3% | Medium | 0.013607709218149423 | https://leetcode.com/problems/find-peak-element |
| 12 | 14 | Longest Common Prefix | 35.4% | Easy | 0.012650390082165711 | https://leetcode.com/problems/longest-common-prefix |
| 13 | 227 | Basic Calculator II | 36.9% | Medium | 0.0118801516064451 | https://leetcode.com/problems/basic-calculator-ii |
| 14 | 518 | Coin Change 2 | 50.2% | Medium | 0.011844971180548993 | https://leetcode.com/problems/coin-change-2 |
| 15 | 33 | Search in Rotated Sorted Array | 34.5% | Medium | 0.0031000567336666443 | https://leetcode.com/problems/search-in-rotated-sorted-array |