Files
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

16 lines
1.6 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
236,Lowest Common Ancestor of a Binary Tree,45.7%,Medium,0.06122838444838759, https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
437,Path Sum III,47.2%,Medium,0.04550116684579005, https://leetcode.com/problems/path-sum-iii
443,String Compression,41.3%,Easy,0.029773949243192512, https://leetcode.com/problems/string-compression
981,Time Based Key-Value Store,53.1%,Medium,0.02132276946882123, https://leetcode.com/problems/time-based-key-value-store
146,LRU Cache,33.2%,Medium,0.017369086240613615, https://leetcode.com/problems/lru-cache
127,Word Ladder,29.6%,Medium,0.012849976929025548, https://leetcode.com/problems/word-ladder
273,Integer to English Words,27.1%,Hard,0.01153415324528653, https://leetcode.com/problems/integer-to-english-words
387,First Unique Character in a String,53.4%,Easy,0.008959741371471904, https://leetcode.com/problems/first-unique-character-in-a-string
20,Valid Parentheses,39.0%,Easy,0.004938010692392608, https://leetcode.com/problems/valid-parentheses
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
283,Move Zeroes,57.8%,Easy,0.002758622439079723, https://leetcode.com/problems/move-zeroes
53,Maximum Subarray,46.5%,Easy,0.0020745819379855658, https://leetcode.com/problems/maximum-subarray
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0014852223137141987, https://leetcode.com/problems/longest-substring-without-repeating-characters