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,15 +1,16 @@
592,Fraction Addition and Subtraction,49.0%,Medium,2.1852914017256673, https://leetcode.com/problems/fraction-addition-and-subtraction
691,Stickers to Spell Word,42.9%,Hard,1.614456743546043, https://leetcode.com/problems/stickers-to-spell-word
598,Range Addition II,49.6%,Easy,1.5459245067117746, https://leetcode.com/problems/range-addition-ii
634,Find the Derangement of An Array,40.1%,Medium,1.3910002521573033, https://leetcode.com/problems/find-the-derangement-of-an-array
166,Fraction to Recurring Decimal,21.6%,Medium,1.1471239400937834, https://leetcode.com/problems/fraction-to-recurring-decimal
697,Degree of an Array,53.8%,Easy,0.5762892819141592, https://leetcode.com/problems/degree-of-an-array
717,1-bit and 2-bit Characters,48.8%,Easy,0.33241507811894616, https://leetcode.com/problems/1-bit-and-2-bit-characters
14,Longest Common Prefix,35.4%,Easy,0.276319223139963, https://leetcode.com/problems/longest-common-prefix
945,Minimum Increment to Make Array Unique,46.3%,Medium,0.26121549926361765, https://leetcode.com/problems/minimum-increment-to-make-array-unique
234,Palindrome Linked List,39.3%,Easy,0.19278946654918988, https://leetcode.com/problems/palindrome-linked-list
23,Merge k Sorted Lists,40.2%,Hard,0.1308579191643603, https://leetcode.com/problems/merge-k-sorted-lists
227,Basic Calculator II,36.9%,Medium,0.07203574248429732, https://leetcode.com/problems/basic-calculator-ii
518,Coin Change 2,50.2%,Medium,0.04656063549394753, https://leetcode.com/problems/coin-change-2
33,Search in Rotated Sorted Array,34.5%,Medium,0.03732913608127183, https://leetcode.com/problems/search-in-rotated-sorted-array
162,Find Peak Element,43.3%,Medium,0.013607709218149423, https://leetcode.com/problems/find-peak-element
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
592,Fraction Addition and Subtraction,49.0%,Medium,2.1852914017256673, https://leetcode.com/problems/fraction-addition-and-subtraction
691,Stickers to Spell Word,42.9%,Hard,1.614456743546043, https://leetcode.com/problems/stickers-to-spell-word
598,Range Addition II,49.6%,Easy,1.5459245067117746, https://leetcode.com/problems/range-addition-ii
634,Find the Derangement of An Array,40.1%,Medium,1.3910002521573033, https://leetcode.com/problems/find-the-derangement-of-an-array
166,Fraction to Recurring Decimal,21.6%,Medium,1.1471239400937834, https://leetcode.com/problems/fraction-to-recurring-decimal
697,Degree of an Array,53.8%,Easy,0.5762892819141592, https://leetcode.com/problems/degree-of-an-array
717,1-bit and 2-bit Characters,48.8%,Easy,0.33241507811894616, https://leetcode.com/problems/1-bit-and-2-bit-characters
14,Longest Common Prefix,35.4%,Easy,0.276319223139963, https://leetcode.com/problems/longest-common-prefix
945,Minimum Increment to Make Array Unique,46.3%,Medium,0.26121549926361765, https://leetcode.com/problems/minimum-increment-to-make-array-unique
234,Palindrome Linked List,39.3%,Easy,0.19278946654918988, https://leetcode.com/problems/palindrome-linked-list
23,Merge k Sorted Lists,40.2%,Hard,0.1308579191643603, https://leetcode.com/problems/merge-k-sorted-lists
227,Basic Calculator II,36.9%,Medium,0.07203574248429732, https://leetcode.com/problems/basic-calculator-ii
518,Coin Change 2,50.2%,Medium,0.04656063549394753, https://leetcode.com/problems/coin-change-2
33,Search in Rotated Sorted Array,34.5%,Medium,0.03732913608127183, https://leetcode.com/problems/search-in-rotated-sorted-array
162,Find Peak Element,43.3%,Medium,0.013607709218149423, https://leetcode.com/problems/find-peak-element
1 592 ID Fraction Addition and Subtraction Title 49.0% Acceptance Medium Difficulty 2.1852914017256673 Frequency https://leetcode.com/problems/fraction-addition-and-subtraction Leetcode Question Link
2 691 592 Stickers to Spell Word Fraction Addition and Subtraction 42.9% 49.0% Hard Medium 1.614456743546043 2.1852914017256673 https://leetcode.com/problems/stickers-to-spell-word https://leetcode.com/problems/fraction-addition-and-subtraction
3 598 691 Range Addition II Stickers to Spell Word 49.6% 42.9% Easy Hard 1.5459245067117746 1.614456743546043 https://leetcode.com/problems/range-addition-ii https://leetcode.com/problems/stickers-to-spell-word
4 634 598 Find the Derangement of An Array Range Addition II 40.1% 49.6% Medium Easy 1.3910002521573033 1.5459245067117746 https://leetcode.com/problems/find-the-derangement-of-an-array https://leetcode.com/problems/range-addition-ii
5 166 634 Fraction to Recurring Decimal Find the Derangement of An Array 21.6% 40.1% Medium Medium 1.1471239400937834 1.3910002521573033 https://leetcode.com/problems/fraction-to-recurring-decimal https://leetcode.com/problems/find-the-derangement-of-an-array
6 697 166 Degree of an Array Fraction to Recurring Decimal 53.8% 21.6% Easy Medium 0.5762892819141592 1.1471239400937834 https://leetcode.com/problems/degree-of-an-array https://leetcode.com/problems/fraction-to-recurring-decimal
7 717 697 1-bit and 2-bit Characters Degree of an Array 48.8% 53.8% Easy Easy 0.33241507811894616 0.5762892819141592 https://leetcode.com/problems/1-bit-and-2-bit-characters https://leetcode.com/problems/degree-of-an-array
8 14 717 Longest Common Prefix 1-bit and 2-bit Characters 35.4% 48.8% Easy Easy 0.276319223139963 0.33241507811894616 https://leetcode.com/problems/longest-common-prefix https://leetcode.com/problems/1-bit-and-2-bit-characters
9 945 14 Minimum Increment to Make Array Unique Longest Common Prefix 46.3% 35.4% Medium Easy 0.26121549926361765 0.276319223139963 https://leetcode.com/problems/minimum-increment-to-make-array-unique https://leetcode.com/problems/longest-common-prefix
10 234 945 Palindrome Linked List Minimum Increment to Make Array Unique 39.3% 46.3% Easy Medium 0.19278946654918988 0.26121549926361765 https://leetcode.com/problems/palindrome-linked-list https://leetcode.com/problems/minimum-increment-to-make-array-unique
11 23 234 Merge k Sorted Lists Palindrome Linked List 40.2% 39.3% Hard Easy 0.1308579191643603 0.19278946654918988 https://leetcode.com/problems/merge-k-sorted-lists https://leetcode.com/problems/palindrome-linked-list
12 227 23 Basic Calculator II Merge k Sorted Lists 36.9% 40.2% Medium Hard 0.07203574248429732 0.1308579191643603 https://leetcode.com/problems/basic-calculator-ii https://leetcode.com/problems/merge-k-sorted-lists
13 518 227 Coin Change 2 Basic Calculator II 50.2% 36.9% Medium Medium 0.04656063549394753 0.07203574248429732 https://leetcode.com/problems/coin-change-2 https://leetcode.com/problems/basic-calculator-ii
14 33 518 Search in Rotated Sorted Array Coin Change 2 34.5% 50.2% Medium Medium 0.03732913608127183 0.04656063549394753 https://leetcode.com/problems/search-in-rotated-sorted-array https://leetcode.com/problems/coin-change-2
15 162 33 Find Peak Element Search in Rotated Sorted Array 43.3% 34.5% Medium Medium 0.013607709218149423 0.03732913608127183 https://leetcode.com/problems/find-peak-element https://leetcode.com/problems/search-in-rotated-sorted-array
16 162 Find Peak Element 43.3% Medium 0.013607709218149423 https://leetcode.com/problems/find-peak-element