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)
```
22 lines
2.2 KiB
CSV
22 lines
2.2 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
695,Max Area of Island,62.7%,Medium,0.7679307328544888, https://leetcode.com/problems/max-area-of-island
|
|
759,Employee Free Time,66.3%,Hard,0.754042350785198, https://leetcode.com/problems/employee-free-time
|
|
1229,Meeting Scheduler,52.7%,Medium,0.5152176154540078, https://leetcode.com/problems/meeting-scheduler
|
|
1359,Count All Valid Pickup and Delivery Options,57.9%,Hard,0.4639892692240469, https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options
|
|
355,Design Twitter,30.3%,Medium,0.43160716401293453, https://leetcode.com/problems/design-twitter
|
|
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.19278242868174433, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
|
|
1174,Immediate Food Delivery II,58.5%,Medium,0.12555653398976382, https://leetcode.com/problems/immediate-food-delivery-ii
|
|
210,Course Schedule II,40.7%,Medium,0.10207384808971935, https://leetcode.com/problems/course-schedule-ii
|
|
227,Basic Calculator II,36.9%,Medium,0.07508779675444797, https://leetcode.com/problems/basic-calculator-ii
|
|
1173,Immediate Food Delivery I,80.4%,Easy,0.06592172080482424, https://leetcode.com/problems/immediate-food-delivery-i
|
|
528,Random Pick with Weight,43.9%,Medium,0.03306693626657339, https://leetcode.com/problems/random-pick-with-weight
|
|
348,Design Tic-Tac-Toe,54.3%,Medium,0.024214258120594613, https://leetcode.com/problems/design-tic-tac-toe
|
|
37,Sudoku Solver,43.6%,Hard,0.01821543989134118, https://leetcode.com/problems/sudoku-solver
|
|
56,Merge Intervals,39.3%,Medium,0.013819532422258866, https://leetcode.com/problems/merge-intervals
|
|
269,Alien Dictionary,33.3%,Hard,0.012730916694039954, https://leetcode.com/problems/alien-dictionary
|
|
36,Valid Sudoku,48.7%,Medium,0.007258242715805398, https://leetcode.com/problems/valid-sudoku
|
|
200,Number of Islands,46.8%,Medium,0.006490251382779317, https://leetcode.com/problems/number-of-islands
|
|
15,3Sum,26.8%,Medium,0.004940992758742591, https://leetcode.com/problems/3sum
|
|
146,LRU Cache,33.2%,Medium,0.004600353139061353, https://leetcode.com/problems/lru-cache
|
|
20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses
|