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,10 +1,11 @@
1228,Missing Number In Arithmetic Progression,52.6%,Easy,0.14893621100754167, https://leetcode.com/problems/missing-number-in-arithmetic-progression
545,Boundary of Binary Tree,38.9%,Medium,0.0877756108823857, https://leetcode.com/problems/boundary-of-binary-tree
472,Concatenated Words,43.7%,Hard,0.026615010757229714, https://leetcode.com/problems/concatenated-words
140,Word Break II,32.6%,Hard,0.01660836687673306, https://leetcode.com/problems/word-break-ii
73,Set Matrix Zeroes,43.1%,Medium,0.015010288493889185, https://leetcode.com/problems/set-matrix-zeroes
200,Number of Islands,46.8%,Medium,0.011015601921505717, https://leetcode.com/problems/number-of-islands
937,Reorder Data in Log Files,54.3%,Easy,0.00802733590076424, https://leetcode.com/problems/reorder-data-in-log-files
42,Trapping Rain Water,48.9%,Hard,0.00411947029523883, https://leetcode.com/problems/trapping-rain-water
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
1228,Missing Number In Arithmetic Progression,52.6%,Easy,0.14893621100754167, https://leetcode.com/problems/missing-number-in-arithmetic-progression
545,Boundary of Binary Tree,38.9%,Medium,0.0877756108823857, https://leetcode.com/problems/boundary-of-binary-tree
472,Concatenated Words,43.7%,Hard,0.026615010757229714, https://leetcode.com/problems/concatenated-words
140,Word Break II,32.6%,Hard,0.01660836687673306, https://leetcode.com/problems/word-break-ii
73,Set Matrix Zeroes,43.1%,Medium,0.015010288493889185, https://leetcode.com/problems/set-matrix-zeroes
200,Number of Islands,46.8%,Medium,0.011015601921505717, https://leetcode.com/problems/number-of-islands
937,Reorder Data in Log Files,54.3%,Easy,0.00802733590076424, https://leetcode.com/problems/reorder-data-in-log-files
42,Trapping Rain Water,48.9%,Hard,0.00411947029523883, https://leetcode.com/problems/trapping-rain-water
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
1 1228 ID Missing Number In Arithmetic Progression Title 52.6% Acceptance Easy Difficulty 0.14893621100754167 Frequency https://leetcode.com/problems/missing-number-in-arithmetic-progression Leetcode Question Link
2 545 1228 Boundary of Binary Tree Missing Number In Arithmetic Progression 38.9% 52.6% Medium Easy 0.0877756108823857 0.14893621100754167 https://leetcode.com/problems/boundary-of-binary-tree https://leetcode.com/problems/missing-number-in-arithmetic-progression
3 472 545 Concatenated Words Boundary of Binary Tree 43.7% 38.9% Hard Medium 0.026615010757229714 0.0877756108823857 https://leetcode.com/problems/concatenated-words https://leetcode.com/problems/boundary-of-binary-tree
4 140 472 Word Break II Concatenated Words 32.6% 43.7% Hard Hard 0.01660836687673306 0.026615010757229714 https://leetcode.com/problems/word-break-ii https://leetcode.com/problems/concatenated-words
5 73 140 Set Matrix Zeroes Word Break II 43.1% 32.6% Medium Hard 0.015010288493889185 0.01660836687673306 https://leetcode.com/problems/set-matrix-zeroes https://leetcode.com/problems/word-break-ii
6 200 73 Number of Islands Set Matrix Zeroes 46.8% 43.1% Medium Medium 0.011015601921505717 0.015010288493889185 https://leetcode.com/problems/number-of-islands https://leetcode.com/problems/set-matrix-zeroes
7 937 200 Reorder Data in Log Files Number of Islands 54.3% 46.8% Easy Medium 0.00802733590076424 0.011015601921505717 https://leetcode.com/problems/reorder-data-in-log-files https://leetcode.com/problems/number-of-islands
8 42 937 Trapping Rain Water Reorder Data in Log Files 48.9% 54.3% Hard Easy 0.00411947029523883 0.00802733590076424 https://leetcode.com/problems/trapping-rain-water https://leetcode.com/problems/reorder-data-in-log-files
9 139 42 Word Break Trapping Rain Water 40.1% 48.9% Medium Hard 0.003755167762323698 0.00411947029523883 https://leetcode.com/problems/word-break https://leetcode.com/problems/trapping-rain-water
10 121 139 Best Time to Buy and Sell Stock Word Break 50.5% 40.1% Easy Medium 0.0020383211296970956 0.003755167762323698 https://leetcode.com/problems/best-time-to-buy-and-sell-stock https://leetcode.com/problems/word-break
11 121 Best Time to Buy and Sell Stock 50.5% Easy 0.0020383211296970956 https://leetcode.com/problems/best-time-to-buy-and-sell-stock