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,14 +1,15 @@
984,String Without AAA or BBB,37.7%,Medium,0.4954247677613364, https://leetcode.com/problems/string-without-aaa-or-bbb
915,Partition Array into Disjoint Intervals,45.4%,Medium,0.37292635232139065, https://leetcode.com/problems/partition-array-into-disjoint-intervals
983,Minimum Cost For Tickets,60.5%,Medium,0.26701398643191887, https://leetcode.com/problems/minimum-cost-for-tickets
527,Word Abbreviation,54.3%,Hard,0.24362208265775043, https://leetcode.com/problems/word-abbreviation
1017,Convert to Base -2,59.0%,Medium,0.17904823144898546, https://leetcode.com/problems/convert-to-base-2
1253,Reconstruct a 2-Row Binary Matrix,40.4%,Medium,0.16098937604759944, https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix
42,Trapping Rain Water,48.9%,Hard,0.038490960607653675, https://leetcode.com/problems/trapping-rain-water
2,Add Two Numbers,33.9%,Medium,0.020491663368639005, https://leetcode.com/problems/add-two-numbers
41,First Missing Positive,32.0%,Hard,0.014368063266920193, https://leetcode.com/problems/first-missing-positive
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.00846879565300311, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
234,Palindrome Linked List,39.3%,Easy,0.004533613114828982, https://leetcode.com/problems/palindrome-linked-list
238,Product of Array Except Self,60.1%,Medium,0.003930436424724545, https://leetcode.com/problems/product-of-array-except-self
215,Kth Largest Element in an Array,55.4%,Medium,0.003902443976931749, https://leetcode.com/problems/kth-largest-element-in-an-array
1073,Adding Two Negabinary Numbers,34.2%,Medium,0, https://leetcode.com/problems/adding-two-negabinary-numbers
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
984,String Without AAA or BBB,37.7%,Medium,0.4954247677613364, https://leetcode.com/problems/string-without-aaa-or-bbb
915,Partition Array into Disjoint Intervals,45.4%,Medium,0.37292635232139065, https://leetcode.com/problems/partition-array-into-disjoint-intervals
983,Minimum Cost For Tickets,60.5%,Medium,0.26701398643191887, https://leetcode.com/problems/minimum-cost-for-tickets
527,Word Abbreviation,54.3%,Hard,0.24362208265775043, https://leetcode.com/problems/word-abbreviation
1017,Convert to Base -2,59.0%,Medium,0.17904823144898546, https://leetcode.com/problems/convert-to-base-2
1253,Reconstruct a 2-Row Binary Matrix,40.4%,Medium,0.16098937604759944, https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix
42,Trapping Rain Water,48.9%,Hard,0.038490960607653675, https://leetcode.com/problems/trapping-rain-water
2,Add Two Numbers,33.9%,Medium,0.020491663368639005, https://leetcode.com/problems/add-two-numbers
41,First Missing Positive,32.0%,Hard,0.014368063266920193, https://leetcode.com/problems/first-missing-positive
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.00846879565300311, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
234,Palindrome Linked List,39.3%,Easy,0.004533613114828982, https://leetcode.com/problems/palindrome-linked-list
238,Product of Array Except Self,60.1%,Medium,0.003930436424724545, https://leetcode.com/problems/product-of-array-except-self
215,Kth Largest Element in an Array,55.4%,Medium,0.003902443976931749, https://leetcode.com/problems/kth-largest-element-in-an-array
1073,Adding Two Negabinary Numbers,34.2%,Medium,0, https://leetcode.com/problems/adding-two-negabinary-numbers
1 984 ID String Without AAA or BBB Title 37.7% Acceptance Medium Difficulty 0.4954247677613364 Frequency https://leetcode.com/problems/string-without-aaa-or-bbb Leetcode Question Link
2 915 984 Partition Array into Disjoint Intervals String Without AAA or BBB 45.4% 37.7% Medium Medium 0.37292635232139065 0.4954247677613364 https://leetcode.com/problems/partition-array-into-disjoint-intervals https://leetcode.com/problems/string-without-aaa-or-bbb
3 983 915 Minimum Cost For Tickets Partition Array into Disjoint Intervals 60.5% 45.4% Medium Medium 0.26701398643191887 0.37292635232139065 https://leetcode.com/problems/minimum-cost-for-tickets https://leetcode.com/problems/partition-array-into-disjoint-intervals
4 527 983 Word Abbreviation Minimum Cost For Tickets 54.3% 60.5% Hard Medium 0.24362208265775043 0.26701398643191887 https://leetcode.com/problems/word-abbreviation https://leetcode.com/problems/minimum-cost-for-tickets
5 1017 527 Convert to Base -2 Word Abbreviation 59.0% 54.3% Medium Hard 0.17904823144898546 0.24362208265775043 https://leetcode.com/problems/convert-to-base-2 https://leetcode.com/problems/word-abbreviation
6 1253 1017 Reconstruct a 2-Row Binary Matrix Convert to Base -2 40.4% 59.0% Medium Medium 0.16098937604759944 0.17904823144898546 https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix https://leetcode.com/problems/convert-to-base-2
7 42 1253 Trapping Rain Water Reconstruct a 2-Row Binary Matrix 48.9% 40.4% Hard Medium 0.038490960607653675 0.16098937604759944 https://leetcode.com/problems/trapping-rain-water https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix
8 2 42 Add Two Numbers Trapping Rain Water 33.9% 48.9% Medium Hard 0.020491663368639005 0.038490960607653675 https://leetcode.com/problems/add-two-numbers https://leetcode.com/problems/trapping-rain-water
9 41 2 First Missing Positive Add Two Numbers 32.0% 33.9% Hard Medium 0.014368063266920193 0.020491663368639005 https://leetcode.com/problems/first-missing-positive https://leetcode.com/problems/add-two-numbers
10 121 41 Best Time to Buy and Sell Stock First Missing Positive 50.5% 32.0% Easy Hard 0.00846879565300311 0.014368063266920193 https://leetcode.com/problems/best-time-to-buy-and-sell-stock https://leetcode.com/problems/first-missing-positive
11 234 121 Palindrome Linked List Best Time to Buy and Sell Stock 39.3% 50.5% Easy Easy 0.004533613114828982 0.00846879565300311 https://leetcode.com/problems/palindrome-linked-list https://leetcode.com/problems/best-time-to-buy-and-sell-stock
12 238 234 Product of Array Except Self Palindrome Linked List 60.1% 39.3% Medium Easy 0.003930436424724545 0.004533613114828982 https://leetcode.com/problems/product-of-array-except-self https://leetcode.com/problems/palindrome-linked-list
13 215 238 Kth Largest Element in an Array Product of Array Except Self 55.4% 60.1% Medium Medium 0.003902443976931749 0.003930436424724545 https://leetcode.com/problems/kth-largest-element-in-an-array https://leetcode.com/problems/product-of-array-except-self
14 1073 215 Adding Two Negabinary Numbers Kth Largest Element in an Array 34.2% 55.4% Medium Medium 0 0.003902443976931749 https://leetcode.com/problems/adding-two-negabinary-numbers https://leetcode.com/problems/kth-largest-element-in-an-array
15 1073 Adding Two Negabinary Numbers 34.2% Medium 0 https://leetcode.com/problems/adding-two-negabinary-numbers