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,9 +1,10 @@
221,Maximal Square,37.7%,Medium,0.02632882130640434, https://leetcode.com/problems/maximal-square
617,Merge Two Binary Trees,74.1%,Easy,0.017748444595195822, https://leetcode.com/problems/merge-two-binary-trees
45,Jump Game II,30.6%,Hard,0.0091680678839873, https://leetcode.com/problems/jump-game-ii
91,Decode Ways,24.7%,Medium,0.005747142255567971, https://leetcode.com/problems/decode-ways
69,Sqrt(x),33.9%,Easy,0.004881034705914313, https://leetcode.com/problems/sqrtx
2,Add Two Numbers,33.9%,Medium,0.003640486182288058, https://leetcode.com/problems/add-two-numbers
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.003338653544516847, https://leetcode.com/problems/longest-substring-without-repeating-characters
70,Climbing Stairs,47.8%,Easy,0.0014753073158671238, https://leetcode.com/problems/climbing-stairs
1,Two Sum,45.6%,Easy,0.000785823780173602, https://leetcode.com/problems/two-sum
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
221,Maximal Square,37.7%,Medium,0.02632882130640434, https://leetcode.com/problems/maximal-square
617,Merge Two Binary Trees,74.1%,Easy,0.017748444595195822, https://leetcode.com/problems/merge-two-binary-trees
45,Jump Game II,30.6%,Hard,0.0091680678839873, https://leetcode.com/problems/jump-game-ii
91,Decode Ways,24.7%,Medium,0.005747142255567971, https://leetcode.com/problems/decode-ways
69,Sqrt(x),33.9%,Easy,0.004881034705914313, https://leetcode.com/problems/sqrtx
2,Add Two Numbers,33.9%,Medium,0.003640486182288058, https://leetcode.com/problems/add-two-numbers
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.003338653544516847, https://leetcode.com/problems/longest-substring-without-repeating-characters
70,Climbing Stairs,47.8%,Easy,0.0014753073158671238, https://leetcode.com/problems/climbing-stairs
1,Two Sum,45.6%,Easy,0.000785823780173602, https://leetcode.com/problems/two-sum
1 221 ID Maximal Square Title 37.7% Acceptance Medium Difficulty 0.02632882130640434 Frequency https://leetcode.com/problems/maximal-square Leetcode Question Link
2 617 221 Merge Two Binary Trees Maximal Square 74.1% 37.7% Easy Medium 0.017748444595195822 0.02632882130640434 https://leetcode.com/problems/merge-two-binary-trees https://leetcode.com/problems/maximal-square
3 45 617 Jump Game II Merge Two Binary Trees 30.6% 74.1% Hard Easy 0.0091680678839873 0.017748444595195822 https://leetcode.com/problems/jump-game-ii https://leetcode.com/problems/merge-two-binary-trees
4 91 45 Decode Ways Jump Game II 24.7% 30.6% Medium Hard 0.005747142255567971 0.0091680678839873 https://leetcode.com/problems/decode-ways https://leetcode.com/problems/jump-game-ii
5 69 91 Sqrt(x) Decode Ways 33.9% 24.7% Easy Medium 0.004881034705914313 0.005747142255567971 https://leetcode.com/problems/sqrtx https://leetcode.com/problems/decode-ways
6 2 69 Add Two Numbers Sqrt(x) 33.9% 33.9% Medium Easy 0.003640486182288058 0.004881034705914313 https://leetcode.com/problems/add-two-numbers https://leetcode.com/problems/sqrtx
7 3 2 Longest Substring Without Repeating Characters Add Two Numbers 30.4% 33.9% Medium Medium 0.003338653544516847 0.003640486182288058 https://leetcode.com/problems/longest-substring-without-repeating-characters https://leetcode.com/problems/add-two-numbers
8 70 3 Climbing Stairs Longest Substring Without Repeating Characters 47.8% 30.4% Easy Medium 0.0014753073158671238 0.003338653544516847 https://leetcode.com/problems/climbing-stairs https://leetcode.com/problems/longest-substring-without-repeating-characters
9 1 70 Two Sum Climbing Stairs 45.6% 47.8% Easy Easy 0.000785823780173602 0.0014753073158671238 https://leetcode.com/problems/two-sum https://leetcode.com/problems/climbing-stairs
10 1 Two Sum 45.6% Easy 0.000785823780173602 https://leetcode.com/problems/two-sum