Files
LeetCode-Questions-CompanyWise/houzz_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

18 lines
1.8 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
227,Basic Calculator II,36.9%,Medium,0.10614463594818956, https://leetcode.com/problems/basic-calculator-ii
43,Multiply Strings,33.9%,Medium,0.07944184170158367, https://leetcode.com/problems/multiply-strings
721,Accounts Merge,48.8%,Medium,0.07349495575336484, https://leetcode.com/problems/accounts-merge
556,Next Greater Element III,31.7%,Medium,0.04679216150675895, https://leetcode.com/problems/next-greater-element-iii
727,Minimum Window Subsequence,41.8%,Hard,0.04237922296886145, https://leetcode.com/problems/minimum-window-subsequence
304,Range Sum Query 2D - Immutable,38.6%,Medium,0.031036973995576488, https://leetcode.com/problems/range-sum-query-2d-immutable
218,The Skyline Problem,34.6%,Hard,0.025479085300984906, https://leetcode.com/problems/the-skyline-problem
698,Partition to K Equal Sum Subsets,45.0%,Medium,0.02109782896463587, https://leetcode.com/problems/partition-to-k-equal-sum-subsets
301,Remove Invalid Parentheses,43.3%,Hard,0.01446679841775339, https://leetcode.com/problems/remove-invalid-parentheses
120,Triangle,44.2%,Medium,0.013236460625830901, https://leetcode.com/problems/triangle
200,Number of Islands,46.8%,Medium,0.011509262420590827, https://leetcode.com/problems/number-of-islands
48,Rotate Image,56.7%,Medium,0.011428695823622754, https://leetcode.com/problems/rotate-image
212,Word Search II,34.9%,Hard,0.009845021678804893, https://leetcode.com/problems/word-search-ii
10,Regular Expression Matching,26.8%,Hard,0.0071865203293987245, https://leetcode.com/problems/regular-expression-matching
31,Next Permutation,32.6%,Medium,0.005989835219179644, https://leetcode.com/problems/next-permutation
4,Median of Two Sorted Arrays,29.6%,Hard,0.003900160950094767, https://leetcode.com/problems/median-of-two-sorted-arrays