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)

```
This commit is contained in:
Krishna Kumar Dey
2023-04-01 11:07:49 +05:30
committed by GitHub
parent 0aeadbd612
commit fb5f78b55e
534 changed files with 20291 additions and 19757 deletions

View File

@@ -1,4 +1,5 @@
291,Word Pattern II,43.4%,Hard,0.4894087826129644, https://leetcode.com/problems/word-pattern-ii
786,K-th Smallest Prime Fraction,41.0%,Hard,0.2608348224155929, https://leetcode.com/problems/k-th-smallest-prime-fraction
301,Remove Invalid Parentheses,43.3%,Hard,0.03226086221822144, https://leetcode.com/problems/remove-invalid-parentheses
1235,Maximum Profit in Job Scheduling,44.0%,Hard,0, https://leetcode.com/problems/maximum-profit-in-job-scheduling
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
291,Word Pattern II,43.4%,Hard,0.4894087826129644, https://leetcode.com/problems/word-pattern-ii
786,K-th Smallest Prime Fraction,41.0%,Hard,0.2608348224155929, https://leetcode.com/problems/k-th-smallest-prime-fraction
301,Remove Invalid Parentheses,43.3%,Hard,0.03226086221822144, https://leetcode.com/problems/remove-invalid-parentheses
1235,Maximum Profit in Job Scheduling,44.0%,Hard,0, https://leetcode.com/problems/maximum-profit-in-job-scheduling
1 291 ID Word Pattern II Title 43.4% Acceptance Hard Difficulty 0.4894087826129644 Frequency https://leetcode.com/problems/word-pattern-ii Leetcode Question Link
2 786 291 K-th Smallest Prime Fraction Word Pattern II 41.0% 43.4% Hard Hard 0.2608348224155929 0.4894087826129644 https://leetcode.com/problems/k-th-smallest-prime-fraction https://leetcode.com/problems/word-pattern-ii
3 301 786 Remove Invalid Parentheses K-th Smallest Prime Fraction 43.3% 41.0% Hard Hard 0.03226086221822144 0.2608348224155929 https://leetcode.com/problems/remove-invalid-parentheses https://leetcode.com/problems/k-th-smallest-prime-fraction
4 1235 301 Maximum Profit in Job Scheduling Remove Invalid Parentheses 44.0% 43.3% Hard Hard 0 0.03226086221822144 https://leetcode.com/problems/maximum-profit-in-job-scheduling https://leetcode.com/problems/remove-invalid-parentheses
5 1235 Maximum Profit in Job Scheduling 44.0% Hard 0 https://leetcode.com/problems/maximum-profit-in-job-scheduling