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 @@
286,Walls and Gates,54.5%,Medium,0.04493831094219302, https://leetcode.com/problems/walls-and-gates
383,Ransom Note,53.1%,Easy,0.0326012144306243, https://leetcode.com/problems/ransom-note
784,Letter Case Permutation,64.6%,Medium,0.02026411791905559, https://leetcode.com/problems/letter-case-permutation
22,Generate Parentheses,62.7%,Medium,0.017331456351639924, https://leetcode.com/problems/generate-parentheses
20,Valid Parentheses,39.0%,Easy,0.014292491180025941, https://leetcode.com/problems/valid-parentheses
443,String Compression,41.3%,Medium,0.01390843004613198, https://leetcode.com/problems/string-compression
146,LRU Cache,33.2%,Medium,0.010321192540274932, https://leetcode.com/problems/lru-cache
206,Reverse Linked List,62.5%,Easy,0.009326794511974934, https://leetcode.com/problems/reverse-linked-list
128,Longest Consecutive Sequence,45.1%,Hard,0.009051883485315484, https://leetcode.com/problems/longest-consecutive-sequence
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.006208067119374334, https://leetcode.com/problems/longest-substring-without-repeating-characters
127,Word Ladder,29.6%,Hard,0.005979091056058075, https://leetcode.com/problems/word-ladder
215,Kth Largest Element in an Array,55.4%,Medium,0.003902443976931749, https://leetcode.com/problems/kth-largest-element-in-an-array
200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands
347,Top K Frequent Elements,61.2%,Medium,0.0014856636219477439, https://leetcode.com/problems/top-k-frequent-elements
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
286,Walls and Gates,54.5%,Medium,0.04493831094219302, https://leetcode.com/problems/walls-and-gates
383,Ransom Note,53.1%,Easy,0.0326012144306243, https://leetcode.com/problems/ransom-note
784,Letter Case Permutation,64.6%,Medium,0.02026411791905559, https://leetcode.com/problems/letter-case-permutation
22,Generate Parentheses,62.7%,Medium,0.017331456351639924, https://leetcode.com/problems/generate-parentheses
20,Valid Parentheses,39.0%,Easy,0.014292491180025941, https://leetcode.com/problems/valid-parentheses
443,String Compression,41.3%,Medium,0.01390843004613198, https://leetcode.com/problems/string-compression
146,LRU Cache,33.2%,Medium,0.010321192540274932, https://leetcode.com/problems/lru-cache
206,Reverse Linked List,62.5%,Easy,0.009326794511974934, https://leetcode.com/problems/reverse-linked-list
128,Longest Consecutive Sequence,45.1%,Hard,0.009051883485315484, https://leetcode.com/problems/longest-consecutive-sequence
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.006208067119374334, https://leetcode.com/problems/longest-substring-without-repeating-characters
127,Word Ladder,29.6%,Hard,0.005979091056058075, https://leetcode.com/problems/word-ladder
215,Kth Largest Element in an Array,55.4%,Medium,0.003902443976931749, https://leetcode.com/problems/kth-largest-element-in-an-array
200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands
347,Top K Frequent Elements,61.2%,Medium,0.0014856636219477439, https://leetcode.com/problems/top-k-frequent-elements
1 286 ID Walls and Gates Title 54.5% Acceptance Medium Difficulty 0.04493831094219302 Frequency https://leetcode.com/problems/walls-and-gates Leetcode Question Link
2 383 286 Ransom Note Walls and Gates 53.1% 54.5% Easy Medium 0.0326012144306243 0.04493831094219302 https://leetcode.com/problems/ransom-note https://leetcode.com/problems/walls-and-gates
3 784 383 Letter Case Permutation Ransom Note 64.6% 53.1% Medium Easy 0.02026411791905559 0.0326012144306243 https://leetcode.com/problems/letter-case-permutation https://leetcode.com/problems/ransom-note
4 22 784 Generate Parentheses Letter Case Permutation 62.7% 64.6% Medium Medium 0.017331456351639924 0.02026411791905559 https://leetcode.com/problems/generate-parentheses https://leetcode.com/problems/letter-case-permutation
5 20 22 Valid Parentheses Generate Parentheses 39.0% 62.7% Easy Medium 0.014292491180025941 0.017331456351639924 https://leetcode.com/problems/valid-parentheses https://leetcode.com/problems/generate-parentheses
6 443 20 String Compression Valid Parentheses 41.3% 39.0% Medium Easy 0.01390843004613198 0.014292491180025941 https://leetcode.com/problems/string-compression https://leetcode.com/problems/valid-parentheses
7 146 443 LRU Cache String Compression 33.2% 41.3% Medium Medium 0.010321192540274932 0.01390843004613198 https://leetcode.com/problems/lru-cache https://leetcode.com/problems/string-compression
8 206 146 Reverse Linked List LRU Cache 62.5% 33.2% Easy Medium 0.009326794511974934 0.010321192540274932 https://leetcode.com/problems/reverse-linked-list https://leetcode.com/problems/lru-cache
9 128 206 Longest Consecutive Sequence Reverse Linked List 45.1% 62.5% Hard Easy 0.009051883485315484 0.009326794511974934 https://leetcode.com/problems/longest-consecutive-sequence https://leetcode.com/problems/reverse-linked-list
10 3 128 Longest Substring Without Repeating Characters Longest Consecutive Sequence 30.4% 45.1% Medium Hard 0.006208067119374334 0.009051883485315484 https://leetcode.com/problems/longest-substring-without-repeating-characters https://leetcode.com/problems/longest-consecutive-sequence
11 127 3 Word Ladder Longest Substring Without Repeating Characters 29.6% 30.4% Hard Medium 0.005979091056058075 0.006208067119374334 https://leetcode.com/problems/word-ladder https://leetcode.com/problems/longest-substring-without-repeating-characters
12 215 127 Kth Largest Element in an Array Word Ladder 55.4% 29.6% Medium Hard 0.003902443976931749 0.005979091056058075 https://leetcode.com/problems/kth-largest-element-in-an-array https://leetcode.com/problems/word-ladder
13 200 215 Number of Islands Kth Largest Element in an Array 46.8% 55.4% Medium Medium 0.0028897578265903614 0.003902443976931749 https://leetcode.com/problems/number-of-islands https://leetcode.com/problems/kth-largest-element-in-an-array
14 347 200 Top K Frequent Elements Number of Islands 61.2% 46.8% Medium Medium 0.0014856636219477439 0.0028897578265903614 https://leetcode.com/problems/top-k-frequent-elements https://leetcode.com/problems/number-of-islands
15 347 Top K Frequent Elements 61.2% Medium 0.0014856636219477439 https://leetcode.com/problems/top-k-frequent-elements