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,8 +1,9 @@
166,Fraction to Recurring Decimal,21.6%,Medium,0.3214580219607569, https://leetcode.com/problems/fraction-to-recurring-decimal
945,Minimum Increment to Make Array Unique,46.3%,Medium,0.24996776739863846, https://leetcode.com/problems/minimum-increment-to-make-array-unique
691,Stickers to Spell Word,42.9%,Hard,0.2131528906392817, https://leetcode.com/problems/stickers-to-spell-word
592,Fraction Addition and Subtraction,49.0%,Medium,0.1394125430225106, https://leetcode.com/problems/fraction-addition-and-subtraction
598,Range Addition II,49.6%,Easy,0.0863907376989368, https://leetcode.com/problems/range-addition-ii
14,Longest Common Prefix,35.4%,Easy,0.012650390082165711, https://leetcode.com/problems/longest-common-prefix
234,Palindrome Linked List,39.3%,Easy,0.009716151141728767, https://leetcode.com/problems/palindrome-linked-list
23,Merge k Sorted Lists,40.2%,Hard,0.008699909875545938, https://leetcode.com/problems/merge-k-sorted-lists
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
166,Fraction to Recurring Decimal,21.6%,Medium,0.3214580219607569, https://leetcode.com/problems/fraction-to-recurring-decimal
945,Minimum Increment to Make Array Unique,46.3%,Medium,0.24996776739863846, https://leetcode.com/problems/minimum-increment-to-make-array-unique
691,Stickers to Spell Word,42.9%,Hard,0.2131528906392817, https://leetcode.com/problems/stickers-to-spell-word
592,Fraction Addition and Subtraction,49.0%,Medium,0.1394125430225106, https://leetcode.com/problems/fraction-addition-and-subtraction
598,Range Addition II,49.6%,Easy,0.0863907376989368, https://leetcode.com/problems/range-addition-ii
14,Longest Common Prefix,35.4%,Easy,0.012650390082165711, https://leetcode.com/problems/longest-common-prefix
234,Palindrome Linked List,39.3%,Easy,0.009716151141728767, https://leetcode.com/problems/palindrome-linked-list
23,Merge k Sorted Lists,40.2%,Hard,0.008699909875545938, https://leetcode.com/problems/merge-k-sorted-lists
1 166 ID Fraction to Recurring Decimal Title 21.6% Acceptance Medium Difficulty 0.3214580219607569 Frequency https://leetcode.com/problems/fraction-to-recurring-decimal Leetcode Question Link
2 945 166 Minimum Increment to Make Array Unique Fraction to Recurring Decimal 46.3% 21.6% Medium Medium 0.24996776739863846 0.3214580219607569 https://leetcode.com/problems/minimum-increment-to-make-array-unique https://leetcode.com/problems/fraction-to-recurring-decimal
3 691 945 Stickers to Spell Word Minimum Increment to Make Array Unique 42.9% 46.3% Hard Medium 0.2131528906392817 0.24996776739863846 https://leetcode.com/problems/stickers-to-spell-word https://leetcode.com/problems/minimum-increment-to-make-array-unique
4 592 691 Fraction Addition and Subtraction Stickers to Spell Word 49.0% 42.9% Medium Hard 0.1394125430225106 0.2131528906392817 https://leetcode.com/problems/fraction-addition-and-subtraction https://leetcode.com/problems/stickers-to-spell-word
5 598 592 Range Addition II Fraction Addition and Subtraction 49.6% 49.0% Easy Medium 0.0863907376989368 0.1394125430225106 https://leetcode.com/problems/range-addition-ii https://leetcode.com/problems/fraction-addition-and-subtraction
6 14 598 Longest Common Prefix Range Addition II 35.4% 49.6% Easy Easy 0.012650390082165711 0.0863907376989368 https://leetcode.com/problems/longest-common-prefix https://leetcode.com/problems/range-addition-ii
7 234 14 Palindrome Linked List Longest Common Prefix 39.3% 35.4% Easy Easy 0.009716151141728767 0.012650390082165711 https://leetcode.com/problems/palindrome-linked-list https://leetcode.com/problems/longest-common-prefix
8 23 234 Merge k Sorted Lists Palindrome Linked List 40.2% 39.3% Hard Easy 0.008699909875545938 0.009716151141728767 https://leetcode.com/problems/merge-k-sorted-lists https://leetcode.com/problems/palindrome-linked-list
9 23 Merge k Sorted Lists 40.2% Hard 0.008699909875545938 https://leetcode.com/problems/merge-k-sorted-lists