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,16 +1,17 @@
149,Max Points on a Line,16.9%,Hard,0.08243941611799847, https://leetcode.com/problems/max-points-on-a-line
274,H-Index,36.1%,Medium,0.0632254597089662, https://leetcode.com/problems/h-index
1213,Intersection of Three Sorted Arrays,78.9%,Easy,0.04401150329993394, https://leetcode.com/problems/intersection-of-three-sorted-arrays
692,Top K Frequent Words,51.8%,Medium,0.0439052078041538, https://leetcode.com/problems/top-k-frequent-words
1002,Find Common Characters,67.7%,Easy,0.033176651317732786, https://leetcode.com/problems/find-common-characters
65,Valid Number,15.3%,Hard,0.02168106606132404, https://leetcode.com/problems/valid-number
384,Shuffle an Array,52.8%,Medium,0.014706147389695468, https://leetcode.com/problems/shuffle-an-array
528,Random Pick with Weight,43.9%,Medium,0.014383563329954094, https://leetcode.com/problems/random-pick-with-weight
146,LRU Cache,33.2%,Medium,0.009807205116964715, https://leetcode.com/problems/lru-cache
33,Search in Rotated Sorted Array,34.5%,Medium,0.006961661779487692, https://leetcode.com/problems/search-in-rotated-sorted-array
73,Set Matrix Zeroes,43.1%,Medium,0.006699070439072842, https://leetcode.com/problems/set-matrix-zeroes
98,Validate Binary Search Tree,27.8%,Medium,0.0063060747091605324, https://leetcode.com/problems/validate-binary-search-tree
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
101,Symmetric Tree,46.8%,Easy,0.0032666423495169026, https://leetcode.com/problems/symmetric-tree
206,Reverse Linked List,62.5%,Easy,0.002231770161393673, https://leetcode.com/problems/reverse-linked-list
70,Climbing Stairs,47.8%,Easy,0.0014753073158671238, https://leetcode.com/problems/climbing-stairs
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
149,Max Points on a Line,16.9%,Hard,0.08243941611799847, https://leetcode.com/problems/max-points-on-a-line
274,H-Index,36.1%,Medium,0.0632254597089662, https://leetcode.com/problems/h-index
1213,Intersection of Three Sorted Arrays,78.9%,Easy,0.04401150329993394, https://leetcode.com/problems/intersection-of-three-sorted-arrays
692,Top K Frequent Words,51.8%,Medium,0.0439052078041538, https://leetcode.com/problems/top-k-frequent-words
1002,Find Common Characters,67.7%,Easy,0.033176651317732786, https://leetcode.com/problems/find-common-characters
65,Valid Number,15.3%,Hard,0.02168106606132404, https://leetcode.com/problems/valid-number
384,Shuffle an Array,52.8%,Medium,0.014706147389695468, https://leetcode.com/problems/shuffle-an-array
528,Random Pick with Weight,43.9%,Medium,0.014383563329954094, https://leetcode.com/problems/random-pick-with-weight
146,LRU Cache,33.2%,Medium,0.009807205116964715, https://leetcode.com/problems/lru-cache
33,Search in Rotated Sorted Array,34.5%,Medium,0.006961661779487692, https://leetcode.com/problems/search-in-rotated-sorted-array
73,Set Matrix Zeroes,43.1%,Medium,0.006699070439072842, https://leetcode.com/problems/set-matrix-zeroes
98,Validate Binary Search Tree,27.8%,Medium,0.0063060747091605324, https://leetcode.com/problems/validate-binary-search-tree
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
101,Symmetric Tree,46.8%,Easy,0.0032666423495169026, https://leetcode.com/problems/symmetric-tree
206,Reverse Linked List,62.5%,Easy,0.002231770161393673, https://leetcode.com/problems/reverse-linked-list
70,Climbing Stairs,47.8%,Easy,0.0014753073158671238, https://leetcode.com/problems/climbing-stairs
1 149 ID Max Points on a Line Title 16.9% Acceptance Hard Difficulty 0.08243941611799847 Frequency https://leetcode.com/problems/max-points-on-a-line Leetcode Question Link
2 274 149 H-Index Max Points on a Line 36.1% 16.9% Medium Hard 0.0632254597089662 0.08243941611799847 https://leetcode.com/problems/h-index https://leetcode.com/problems/max-points-on-a-line
3 1213 274 Intersection of Three Sorted Arrays H-Index 78.9% 36.1% Easy Medium 0.04401150329993394 0.0632254597089662 https://leetcode.com/problems/intersection-of-three-sorted-arrays https://leetcode.com/problems/h-index
4 692 1213 Top K Frequent Words Intersection of Three Sorted Arrays 51.8% 78.9% Medium Easy 0.0439052078041538 0.04401150329993394 https://leetcode.com/problems/top-k-frequent-words https://leetcode.com/problems/intersection-of-three-sorted-arrays
5 1002 692 Find Common Characters Top K Frequent Words 67.7% 51.8% Easy Medium 0.033176651317732786 0.0439052078041538 https://leetcode.com/problems/find-common-characters https://leetcode.com/problems/top-k-frequent-words
6 65 1002 Valid Number Find Common Characters 15.3% 67.7% Hard Easy 0.02168106606132404 0.033176651317732786 https://leetcode.com/problems/valid-number https://leetcode.com/problems/find-common-characters
7 384 65 Shuffle an Array Valid Number 52.8% 15.3% Medium Hard 0.014706147389695468 0.02168106606132404 https://leetcode.com/problems/shuffle-an-array https://leetcode.com/problems/valid-number
8 528 384 Random Pick with Weight Shuffle an Array 43.9% 52.8% Medium Medium 0.014383563329954094 0.014706147389695468 https://leetcode.com/problems/random-pick-with-weight https://leetcode.com/problems/shuffle-an-array
9 146 528 LRU Cache Random Pick with Weight 33.2% 43.9% Medium Medium 0.009807205116964715 0.014383563329954094 https://leetcode.com/problems/lru-cache https://leetcode.com/problems/random-pick-with-weight
10 33 146 Search in Rotated Sorted Array LRU Cache 34.5% 33.2% Medium Medium 0.006961661779487692 0.009807205116964715 https://leetcode.com/problems/search-in-rotated-sorted-array https://leetcode.com/problems/lru-cache
11 73 33 Set Matrix Zeroes Search in Rotated Sorted Array 43.1% 34.5% Medium Medium 0.006699070439072842 0.006961661779487692 https://leetcode.com/problems/set-matrix-zeroes https://leetcode.com/problems/search-in-rotated-sorted-array
12 98 73 Validate Binary Search Tree Set Matrix Zeroes 27.8% 43.1% Medium Medium 0.0063060747091605324 0.006699070439072842 https://leetcode.com/problems/validate-binary-search-tree https://leetcode.com/problems/set-matrix-zeroes
13 139 98 Word Break Validate Binary Search Tree 40.1% 27.8% Medium Medium 0.003755167762323698 0.0063060747091605324 https://leetcode.com/problems/word-break https://leetcode.com/problems/validate-binary-search-tree
14 101 139 Symmetric Tree Word Break 46.8% 40.1% Easy Medium 0.0032666423495169026 0.003755167762323698 https://leetcode.com/problems/symmetric-tree https://leetcode.com/problems/word-break
15 206 101 Reverse Linked List Symmetric Tree 62.5% 46.8% Easy Easy 0.002231770161393673 0.0032666423495169026 https://leetcode.com/problems/reverse-linked-list https://leetcode.com/problems/symmetric-tree
16 70 206 Climbing Stairs Reverse Linked List 47.8% 62.5% Easy Easy 0.0014753073158671238 0.002231770161393673 https://leetcode.com/problems/climbing-stairs https://leetcode.com/problems/reverse-linked-list
17 70 Climbing Stairs 47.8% Easy 0.0014753073158671238 https://leetcode.com/problems/climbing-stairs