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,6 +1,7 @@
509,Fibonacci Number,67.2%,Easy,0.03801871583399193, https://leetcode.com/problems/fibonacci-number
115,Distinct Subsequences,38.3%,Hard,0.027798871362742988, https://leetcode.com/problems/distinct-subsequences
20,Valid Parentheses,39.0%,Easy,0.020517047266669974, https://leetcode.com/problems/valid-parentheses
91,Decode Ways,24.7%,Medium,0.013379120336324091, https://leetcode.com/problems/decode-ways
273,Integer to English Words,27.1%,Hard,0.012081089250339716, https://leetcode.com/problems/integer-to-english-words
7,Reverse Integer,25.8%,Easy,0.0018612447790907708, https://leetcode.com/problems/reverse-integer
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
509,Fibonacci Number,67.2%,Easy,0.03801871583399193, https://leetcode.com/problems/fibonacci-number
115,Distinct Subsequences,38.3%,Hard,0.027798871362742988, https://leetcode.com/problems/distinct-subsequences
20,Valid Parentheses,39.0%,Easy,0.020517047266669974, https://leetcode.com/problems/valid-parentheses
91,Decode Ways,24.7%,Medium,0.013379120336324091, https://leetcode.com/problems/decode-ways
273,Integer to English Words,27.1%,Hard,0.012081089250339716, https://leetcode.com/problems/integer-to-english-words
7,Reverse Integer,25.8%,Easy,0.0018612447790907708, https://leetcode.com/problems/reverse-integer
1 509 ID Fibonacci Number Title 67.2% Acceptance Easy Difficulty 0.03801871583399193 Frequency https://leetcode.com/problems/fibonacci-number Leetcode Question Link
2 115 509 Distinct Subsequences Fibonacci Number 38.3% 67.2% Hard Easy 0.027798871362742988 0.03801871583399193 https://leetcode.com/problems/distinct-subsequences https://leetcode.com/problems/fibonacci-number
3 20 115 Valid Parentheses Distinct Subsequences 39.0% 38.3% Easy Hard 0.020517047266669974 0.027798871362742988 https://leetcode.com/problems/valid-parentheses https://leetcode.com/problems/distinct-subsequences
4 91 20 Decode Ways Valid Parentheses 24.7% 39.0% Medium Easy 0.013379120336324091 0.020517047266669974 https://leetcode.com/problems/decode-ways https://leetcode.com/problems/valid-parentheses
5 273 91 Integer to English Words Decode Ways 27.1% 24.7% Hard Medium 0.012081089250339716 0.013379120336324091 https://leetcode.com/problems/integer-to-english-words https://leetcode.com/problems/decode-ways
6 7 273 Reverse Integer Integer to English Words 25.8% 27.1% Easy Hard 0.0018612447790907708 0.012081089250339716 https://leetcode.com/problems/reverse-integer https://leetcode.com/problems/integer-to-english-words
7 7 Reverse Integer 25.8% Easy 0.0018612447790907708 https://leetcode.com/problems/reverse-integer