Files
LeetCode-Questions-CompanyWise/wayfair_alltime.csv
Krishna Kumar Dey fb5f78b55e Chore: Add headers to all the files (#54)
## 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)

```
2023-04-01 11:07:49 +05:30

25 lines
2.5 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
1212,Team Scores in Football Tournament,55.8%,Medium,1.1574169741354225, https://leetcode.com/problems/team-scores-in-football-tournament
840,Magic Squares In Grid,37.3%,Easy,0.7861804130990654, https://leetcode.com/problems/magic-squares-in-grid
1194,Tournament Winners,52.9%,Hard,0.4149438520627081, https://leetcode.com/problems/tournament-winners
811,Subdomain Visit Count,69.9%,Easy,0.35434665417914124, https://leetcode.com/problems/subdomain-visit-count
1204,Last Person to Fit in the Elevator,69.8%,Medium,0.3042113744029915, https://leetcode.com/problems/last-person-to-fit-in-the-elevator
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
1014,Best Sightseeing Pair,52.5%,Medium,0.0903548750399561, https://leetcode.com/problems/best-sightseeing-pair
443,String Compression,41.3%,Easy,0.052333720049023605, https://leetcode.com/problems/string-compression
85,Maximal Rectangle,37.7%,Hard,0.050135812424355455, https://leetcode.com/problems/maximal-rectangle
5,Longest Palindromic Substring,29.5%,Medium,0.034277441353764176, https://leetcode.com/problems/longest-palindromic-substring
412,Fizz Buzz,62.3%,Easy,0.027152525030955416, https://leetcode.com/problems/fizz-buzz
718,Maximum Length of Repeated Subarray,49.4%,Medium,0.02699219201435624, https://leetcode.com/problems/maximum-length-of-repeated-subarray
125,Valid Palindrome,36.7%,Easy,0.023503949324973204, https://leetcode.com/problems/valid-palindrome
184,Department Highest Salary,36.7%,Medium,0.018018505502678313, https://leetcode.com/problems/department-highest-salary
56,Merge Intervals,39.3%,Medium,0.013186279740090647, https://leetcode.com/problems/merge-intervals
69,Sqrt(x),33.9%,Easy,0.010949014489670414, https://leetcode.com/problems/sqrtx
53,Maximum Subarray,46.5%,Easy,0.008272628741228982, https://leetcode.com/problems/maximum-subarray
41,First Missing Positive,32.0%,Hard,0.006163347707668678, https://leetcode.com/problems/first-missing-positive
210,Course Schedule II,40.7%,Medium,0.0018850146957713153, https://leetcode.com/problems/course-schedule-ii
1244,Design A Leaderboard,60.7%,Medium,0, https://leetcode.com/problems/design-a-leaderboard
1405,Longest Happy String,49.0%,Medium,0, https://leetcode.com/problems/longest-happy-string
1193,Monthly Transactions I,68.3%,Medium,0, https://leetcode.com/problems/monthly-transactions-i