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 @@
236,Lowest Common Ancestor of a Binary Tree,45.7%,Medium,0.06122838444838759, https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
437,Path Sum III,47.2%,Medium,0.04550116684579005, https://leetcode.com/problems/path-sum-iii
443,String Compression,41.3%,Easy,0.029773949243192512, https://leetcode.com/problems/string-compression
981,Time Based Key-Value Store,53.1%,Medium,0.02132276946882123, https://leetcode.com/problems/time-based-key-value-store
146,LRU Cache,33.2%,Medium,0.017369086240613615, https://leetcode.com/problems/lru-cache
127,Word Ladder,29.6%,Medium,0.012849976929025548, https://leetcode.com/problems/word-ladder
273,Integer to English Words,27.1%,Hard,0.01153415324528653, https://leetcode.com/problems/integer-to-english-words
387,First Unique Character in a String,53.4%,Easy,0.008959741371471904, https://leetcode.com/problems/first-unique-character-in-a-string
20,Valid Parentheses,39.0%,Easy,0.004938010692392608, https://leetcode.com/problems/valid-parentheses
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
283,Move Zeroes,57.8%,Easy,0.002758622439079723, https://leetcode.com/problems/move-zeroes
53,Maximum Subarray,46.5%,Easy,0.0020745819379855658, https://leetcode.com/problems/maximum-subarray
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0014852223137141987, https://leetcode.com/problems/longest-substring-without-repeating-characters
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
236,Lowest Common Ancestor of a Binary Tree,45.7%,Medium,0.06122838444838759, https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
437,Path Sum III,47.2%,Medium,0.04550116684579005, https://leetcode.com/problems/path-sum-iii
443,String Compression,41.3%,Easy,0.029773949243192512, https://leetcode.com/problems/string-compression
981,Time Based Key-Value Store,53.1%,Medium,0.02132276946882123, https://leetcode.com/problems/time-based-key-value-store
146,LRU Cache,33.2%,Medium,0.017369086240613615, https://leetcode.com/problems/lru-cache
127,Word Ladder,29.6%,Medium,0.012849976929025548, https://leetcode.com/problems/word-ladder
273,Integer to English Words,27.1%,Hard,0.01153415324528653, https://leetcode.com/problems/integer-to-english-words
387,First Unique Character in a String,53.4%,Easy,0.008959741371471904, https://leetcode.com/problems/first-unique-character-in-a-string
20,Valid Parentheses,39.0%,Easy,0.004938010692392608, https://leetcode.com/problems/valid-parentheses
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
283,Move Zeroes,57.8%,Easy,0.002758622439079723, https://leetcode.com/problems/move-zeroes
53,Maximum Subarray,46.5%,Easy,0.0020745819379855658, https://leetcode.com/problems/maximum-subarray
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0014852223137141987, https://leetcode.com/problems/longest-substring-without-repeating-characters
1 236 ID Lowest Common Ancestor of a Binary Tree Title 45.7% Acceptance Medium Difficulty 0.06122838444838759 Frequency https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree Leetcode Question Link
2 437 236 Path Sum III Lowest Common Ancestor of a Binary Tree 47.2% 45.7% Medium Medium 0.04550116684579005 0.06122838444838759 https://leetcode.com/problems/path-sum-iii https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
3 443 437 String Compression Path Sum III 41.3% 47.2% Easy Medium 0.029773949243192512 0.04550116684579005 https://leetcode.com/problems/string-compression https://leetcode.com/problems/path-sum-iii
4 981 443 Time Based Key-Value Store String Compression 53.1% 41.3% Medium Easy 0.02132276946882123 0.029773949243192512 https://leetcode.com/problems/time-based-key-value-store https://leetcode.com/problems/string-compression
5 146 981 LRU Cache Time Based Key-Value Store 33.2% 53.1% Medium Medium 0.017369086240613615 0.02132276946882123 https://leetcode.com/problems/lru-cache https://leetcode.com/problems/time-based-key-value-store
6 127 146 Word Ladder LRU Cache 29.6% 33.2% Medium Medium 0.012849976929025548 0.017369086240613615 https://leetcode.com/problems/word-ladder https://leetcode.com/problems/lru-cache
7 273 127 Integer to English Words Word Ladder 27.1% 29.6% Hard Medium 0.01153415324528653 0.012849976929025548 https://leetcode.com/problems/integer-to-english-words https://leetcode.com/problems/word-ladder
8 387 273 First Unique Character in a String Integer to English Words 53.4% 27.1% Easy Hard 0.008959741371471904 0.01153415324528653 https://leetcode.com/problems/first-unique-character-in-a-string https://leetcode.com/problems/integer-to-english-words
9 20 387 Valid Parentheses First Unique Character in a String 39.0% 53.4% Easy Easy 0.004938010692392608 0.008959741371471904 https://leetcode.com/problems/valid-parentheses https://leetcode.com/problems/first-unique-character-in-a-string
10 139 20 Word Break Valid Parentheses 40.1% 39.0% Medium Easy 0.003755167762323698 0.004938010692392608 https://leetcode.com/problems/word-break https://leetcode.com/problems/valid-parentheses
11 283 139 Move Zeroes Word Break 57.8% 40.1% Easy Medium 0.002758622439079723 0.003755167762323698 https://leetcode.com/problems/move-zeroes https://leetcode.com/problems/word-break
12 53 283 Maximum Subarray Move Zeroes 46.5% 57.8% Easy Easy 0.0020745819379855658 0.002758622439079723 https://leetcode.com/problems/maximum-subarray https://leetcode.com/problems/move-zeroes
13 121 53 Best Time to Buy and Sell Stock Maximum Subarray 50.5% 46.5% Easy Easy 0.0020383211296970956 0.0020745819379855658 https://leetcode.com/problems/best-time-to-buy-and-sell-stock https://leetcode.com/problems/maximum-subarray
14 3 121 Longest Substring Without Repeating Characters Best Time to Buy and Sell Stock 30.4% 50.5% Medium Easy 0.0014852223137141987 0.0020383211296970956 https://leetcode.com/problems/longest-substring-without-repeating-characters https://leetcode.com/problems/best-time-to-buy-and-sell-stock
15 3 Longest Substring Without Repeating Characters 30.4% Medium 0.0014852223137141987 https://leetcode.com/problems/longest-substring-without-repeating-characters