LeetCode-Questions-CompanyWise/capital-one_2year.csv
Krishna Kumar Dey fb5f78b55e
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)

```
2023-04-01 11:07:49 +05:30

1.7 KiB

1IDTitleAcceptanceDifficultyFrequencyLeetcode Question Link
2228Summary Ranges39.5%Medium1.7946310215245758https://leetcode.com/problems/summary-ranges
3814Binary Tree Pruning74.5%Medium1.2701157688808176https://leetcode.com/problems/binary-tree-pruning
4328Odd Even Linked List55.7%Medium1.0030015329709059https://leetcode.com/problems/odd-even-linked-list
5290Word Pattern37.0%Easy0.9843050994030789https://leetcode.com/problems/word-pattern
6138Copy List with Random Pointer36.4%Medium0.9130873453663271https://leetcode.com/problems/copy-list-with-random-pointer
7322Coin Change35.5%Medium0.6463386978371466https://leetcode.com/problems/coin-change
81071Greatest Common Divisor of Strings52.9%Easy0.12182344519338843https://leetcode.com/problems/greatest-common-divisor-of-strings
9204Count Primes31.5%Easy0.06191798620391749https://leetcode.com/problems/count-primes
10412Fizz Buzz62.3%Easy0.04396698989626337https://leetcode.com/problems/fizz-buzz
1153Maximum Subarray46.5%Easy0.019336728821707075https://leetcode.com/problems/maximum-subarray
12273Integer to English Words27.1%Hard0.012081089250339716https://leetcode.com/problems/integer-to-english-words
132Add Two Numbers33.9%Medium0.006737434951993369https://leetcode.com/problems/add-two-numbers
14203Remove Linked List Elements38.6%Easy0.0036496390875494257https://leetcode.com/problems/remove-linked-list-elements
1566Plus One43.0%Easy0.00326211347832938https://leetcode.com/problems/plus-one
1698Validate Binary Search Tree27.8%Medium0.002943776044013381https://leetcode.com/problems/validate-binary-search-tree
1721Merge Two Sorted Lists53.5%Easy0.0022551737583973706https://leetcode.com/problems/merge-two-sorted-lists