LeetCode-Questions-CompanyWise/zillow_1year.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.6 KiB

1IDTitleAcceptanceDifficultyFrequencyLeetcode Question Link
2236Lowest Common Ancestor of a Binary Tree45.7%Medium0.06122838444838759https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
3437Path Sum III47.2%Medium0.04550116684579005https://leetcode.com/problems/path-sum-iii
4443String Compression41.3%Easy0.029773949243192512https://leetcode.com/problems/string-compression
5981Time Based Key-Value Store53.1%Medium0.02132276946882123https://leetcode.com/problems/time-based-key-value-store
6146LRU Cache33.2%Medium0.017369086240613615https://leetcode.com/problems/lru-cache
7127Word Ladder29.6%Medium0.012849976929025548https://leetcode.com/problems/word-ladder
8273Integer to English Words27.1%Hard0.01153415324528653https://leetcode.com/problems/integer-to-english-words
9387First Unique Character in a String53.4%Easy0.008959741371471904https://leetcode.com/problems/first-unique-character-in-a-string
1020Valid Parentheses39.0%Easy0.004938010692392608https://leetcode.com/problems/valid-parentheses
11139Word Break40.1%Medium0.003755167762323698https://leetcode.com/problems/word-break
12283Move Zeroes57.8%Easy0.002758622439079723https://leetcode.com/problems/move-zeroes
1353Maximum Subarray46.5%Easy0.0020745819379855658https://leetcode.com/problems/maximum-subarray
14121Best Time to Buy and Sell Stock50.5%Easy0.0020383211296970956https://leetcode.com/problems/best-time-to-buy-and-sell-stock
153Longest Substring Without Repeating Characters30.4%Medium0.0014852223137141987https://leetcode.com/problems/longest-substring-without-repeating-characters