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,12 +1,13 @@
915,Partition Array into Disjoint Intervals,45.4%,Medium,0.31069289452415816, https://leetcode.com/problems/partition-array-into-disjoint-intervals
984,String Without AAA or BBB,37.7%,Medium,0.2735260204188947, https://leetcode.com/problems/string-without-aaa-or-bbb
527,Word Abbreviation,54.3%,Hard,0.18138862486051793, https://leetcode.com/problems/word-abbreviation
1017,Convert to Base -2,59.0%,Medium,0.11681477365175295, https://leetcode.com/problems/convert-to-base-2
983,Minimum Cost For Tickets,60.5%,Medium,0.02467737809337621, https://leetcode.com/problems/minimum-cost-for-tickets
42,Trapping Rain Water,48.9%,Hard,0.009762524655659178, https://leetcode.com/problems/trapping-rain-water
2,Add Two Numbers,33.9%,Medium,0.006737434951993369, https://leetcode.com/problems/add-two-numbers
41,First Missing Positive,32.0%,Hard,0.0064113058208121855, https://leetcode.com/problems/first-missing-positive
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
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0021239321954525975, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
915,Partition Array into Disjoint Intervals,45.4%,Medium,0.31069289452415816, https://leetcode.com/problems/partition-array-into-disjoint-intervals
984,String Without AAA or BBB,37.7%,Medium,0.2735260204188947, https://leetcode.com/problems/string-without-aaa-or-bbb
527,Word Abbreviation,54.3%,Hard,0.18138862486051793, https://leetcode.com/problems/word-abbreviation
1017,Convert to Base -2,59.0%,Medium,0.11681477365175295, https://leetcode.com/problems/convert-to-base-2
983,Minimum Cost For Tickets,60.5%,Medium,0.02467737809337621, https://leetcode.com/problems/minimum-cost-for-tickets
42,Trapping Rain Water,48.9%,Hard,0.009762524655659178, https://leetcode.com/problems/trapping-rain-water
2,Add Two Numbers,33.9%,Medium,0.006737434951993369, https://leetcode.com/problems/add-two-numbers
41,First Missing Positive,32.0%,Hard,0.0064113058208121855, https://leetcode.com/problems/first-missing-positive
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
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0021239321954525975, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
1 915 ID Partition Array into Disjoint Intervals Title 45.4% Acceptance Medium Difficulty 0.31069289452415816 Frequency https://leetcode.com/problems/partition-array-into-disjoint-intervals Leetcode Question Link
2 984 915 String Without AAA or BBB Partition Array into Disjoint Intervals 37.7% 45.4% Medium Medium 0.2735260204188947 0.31069289452415816 https://leetcode.com/problems/string-without-aaa-or-bbb https://leetcode.com/problems/partition-array-into-disjoint-intervals
3 527 984 Word Abbreviation String Without AAA or BBB 54.3% 37.7% Hard Medium 0.18138862486051793 0.2735260204188947 https://leetcode.com/problems/word-abbreviation https://leetcode.com/problems/string-without-aaa-or-bbb
4 1017 527 Convert to Base -2 Word Abbreviation 59.0% 54.3% Medium Hard 0.11681477365175295 0.18138862486051793 https://leetcode.com/problems/convert-to-base-2 https://leetcode.com/problems/word-abbreviation
5 983 1017 Minimum Cost For Tickets Convert to Base -2 60.5% 59.0% Medium Medium 0.02467737809337621 0.11681477365175295 https://leetcode.com/problems/minimum-cost-for-tickets https://leetcode.com/problems/convert-to-base-2
6 42 983 Trapping Rain Water Minimum Cost For Tickets 48.9% 60.5% Hard Medium 0.009762524655659178 0.02467737809337621 https://leetcode.com/problems/trapping-rain-water https://leetcode.com/problems/minimum-cost-for-tickets
7 2 42 Add Two Numbers Trapping Rain Water 33.9% 48.9% Medium Hard 0.006737434951993369 0.009762524655659178 https://leetcode.com/problems/add-two-numbers https://leetcode.com/problems/trapping-rain-water
8 41 2 First Missing Positive Add Two Numbers 32.0% 33.9% Hard Medium 0.0064113058208121855 0.006737434951993369 https://leetcode.com/problems/first-missing-positive https://leetcode.com/problems/add-two-numbers
9 234 41 Palindrome Linked List First Missing Positive 39.3% 32.0% Easy Hard 0.004533613114828982 0.0064113058208121855 https://leetcode.com/problems/palindrome-linked-list https://leetcode.com/problems/first-missing-positive
10 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
11 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
12 121 215 Best Time to Buy and Sell Stock Kth Largest Element in an Array 50.5% 55.4% Easy Medium 0.0021239321954525975 0.003902443976931749 https://leetcode.com/problems/best-time-to-buy-and-sell-stock https://leetcode.com/problems/kth-largest-element-in-an-array
13 121 Best Time to Buy and Sell Stock 50.5% Easy 0.0021239321954525975 https://leetcode.com/problems/best-time-to-buy-and-sell-stock