mirror of
https://github.com/McSmog/LeetCode-Questions-CompanyWise.git
synced 2026-04-19 08:46: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)
```
16 lines
1.6 KiB
CSV
16 lines
1.6 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
840,Magic Squares In Grid,37.3%,Easy,0.4449565940664958, https://leetcode.com/problems/magic-squares-in-grid
|
|
811,Subdomain Visit Count,69.9%,Easy,0.28185115214098777, https://leetcode.com/problems/subdomain-visit-count
|
|
1189,Maximum Number of Balloons,61.2%,Easy,0.11874571021547974, https://leetcode.com/problems/maximum-number-of-balloons
|
|
759,Employee Free Time,66.3%,Hard,0.10143824284548837, https://leetcode.com/problems/employee-free-time
|
|
1204,Last Person to Fit in the Elevator,69.8%,Medium,0.08515780834030685, https://leetcode.com/problems/last-person-to-fit-in-the-elevator
|
|
1212,Team Scores in Football Tournament,55.8%,Medium,0.07862594238342736, https://leetcode.com/problems/team-scores-in-football-tournament
|
|
85,Maximal Rectangle,37.7%,Hard,0.028510008258377777, https://leetcode.com/problems/maximal-rectangle
|
|
718,Maximum Length of Repeated Subarray,49.4%,Medium,0.02699219201435624, https://leetcode.com/problems/maximum-length-of-repeated-subarray
|
|
56,Merge Intervals,39.3%,Medium,0.0074386655924217485, https://leetcode.com/problems/merge-intervals
|
|
412,Fizz Buzz,62.3%,Easy,0.006857561589870336, https://leetcode.com/problems/fizz-buzz
|
|
69,Sqrt(x),33.9%,Easy,0.004881034705914313, https://leetcode.com/problems/sqrtx
|
|
125,Valid Palindrome,36.7%,Easy,0.0037979536727587773, https://leetcode.com/problems/valid-palindrome
|
|
5,Longest Palindromic Substring,29.5%,Medium,0.0021771085723255794, https://leetcode.com/problems/longest-palindromic-substring
|
|
210,Course Schedule II,40.7%,Medium,0.0018850146957713153, https://leetcode.com/problems/course-schedule-ii
|