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