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,3 +1,4 @@
289,Game of Life,54.5%,Medium,0.4018470204215072, https://leetcode.com/problems/game-of-life
150,Evaluate Reverse Polish Notation,36.3%,Medium,0.20518974769761397, https://leetcode.com/problems/evaluate-reverse-polish-notation
12,Integer to Roman,55.1%,Medium,0.008532474973720734, https://leetcode.com/problems/integer-to-roman
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
289,Game of Life,54.5%,Medium,0.4018470204215072, https://leetcode.com/problems/game-of-life
150,Evaluate Reverse Polish Notation,36.3%,Medium,0.20518974769761397, https://leetcode.com/problems/evaluate-reverse-polish-notation
12,Integer to Roman,55.1%,Medium,0.008532474973720734, https://leetcode.com/problems/integer-to-roman
1 289 ID Game of Life Title 54.5% Acceptance Medium Difficulty 0.4018470204215072 Frequency https://leetcode.com/problems/game-of-life Leetcode Question Link
2 150 289 Evaluate Reverse Polish Notation Game of Life 36.3% 54.5% Medium Medium 0.20518974769761397 0.4018470204215072 https://leetcode.com/problems/evaluate-reverse-polish-notation https://leetcode.com/problems/game-of-life
3 12 150 Integer to Roman Evaluate Reverse Polish Notation 55.1% 36.3% Medium Medium 0.008532474973720734 0.20518974769761397 https://leetcode.com/problems/integer-to-roman https://leetcode.com/problems/evaluate-reverse-polish-notation
4 12 Integer to Roman 55.1% Medium 0.008532474973720734 https://leetcode.com/problems/integer-to-roman