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,5 +1,6 @@
289,Game of Life,54.5%,Medium,0.14824301157875866, https://leetcode.com/problems/game-of-life
314,Binary Tree Vertical Order Traversal,45.3%,Medium,0.10758430200165091, https://leetcode.com/problems/binary-tree-vertical-order-traversal
706,Design HashMap,61.3%,Easy,0.0683442674369718, https://leetcode.com/problems/design-hashmap
227,Basic Calculator II,36.9%,Medium,0.027685557859864054, https://leetcode.com/problems/basic-calculator-ii
987,Vertical Order Traversal of a Binary Tree,36.6%,Medium,0.011601058182762062, https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
289,Game of Life,54.5%,Medium,0.14824301157875866, https://leetcode.com/problems/game-of-life
314,Binary Tree Vertical Order Traversal,45.3%,Medium,0.10758430200165091, https://leetcode.com/problems/binary-tree-vertical-order-traversal
706,Design HashMap,61.3%,Easy,0.0683442674369718, https://leetcode.com/problems/design-hashmap
227,Basic Calculator II,36.9%,Medium,0.027685557859864054, https://leetcode.com/problems/basic-calculator-ii
987,Vertical Order Traversal of a Binary Tree,36.6%,Medium,0.011601058182762062, https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree
1 289 ID Game of Life Title 54.5% Acceptance Medium Difficulty 0.14824301157875866 Frequency https://leetcode.com/problems/game-of-life Leetcode Question Link
2 314 289 Binary Tree Vertical Order Traversal Game of Life 45.3% 54.5% Medium Medium 0.10758430200165091 0.14824301157875866 https://leetcode.com/problems/binary-tree-vertical-order-traversal https://leetcode.com/problems/game-of-life
3 706 314 Design HashMap Binary Tree Vertical Order Traversal 61.3% 45.3% Easy Medium 0.0683442674369718 0.10758430200165091 https://leetcode.com/problems/design-hashmap https://leetcode.com/problems/binary-tree-vertical-order-traversal
4 227 706 Basic Calculator II Design HashMap 36.9% 61.3% Medium Easy 0.027685557859864054 0.0683442674369718 https://leetcode.com/problems/basic-calculator-ii https://leetcode.com/problems/design-hashmap
5 987 227 Vertical Order Traversal of a Binary Tree Basic Calculator II 36.6% 36.9% Medium Medium 0.011601058182762062 0.027685557859864054 https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree https://leetcode.com/problems/basic-calculator-ii
6 987 Vertical Order Traversal of a Binary Tree 36.6% Medium 0.011601058182762062 https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree