Files
LeetCode-Questions-CompanyWise/huawei_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.9 KiB

1IDTitleAcceptanceDifficultyFrequencyLeetcode Question Link
2221Maximal Square37.7%Medium0.07763487926837137https://leetcode.com/problems/maximal-square
3394Decode String50.0%Medium0.0476916619317836https://leetcode.com/problems/decode-string
4617Merge Two Binary Trees74.1%Easy0.017748444595195822https://leetcode.com/problems/merge-two-binary-trees
53Longest Substring Without Repeating Characters30.4%Medium0.00924665389133899https://leetcode.com/problems/longest-substring-without-repeating-characters
645Jump Game II30.6%Hard0.0091680678839873https://leetcode.com/problems/jump-game-ii
743Multiply Strings33.9%Medium0.008745136625358634https://leetcode.com/problems/multiply-strings
81Two Sum45.6%Easy0.007050281837628458https://leetcode.com/problems/two-sum
991Decode Ways24.7%Medium0.005747142255567971https://leetcode.com/problems/decode-ways
1069Sqrt(x)33.9%Easy0.004881034705914313https://leetcode.com/problems/sqrtx
1142Trapping Rain Water48.9%Hard0.00411947029523883https://leetcode.com/problems/trapping-rain-water
12387First Unique Character in a String53.4%Easy0.003992021269537453https://leetcode.com/problems/first-unique-character-in-a-string
134Median of Two Sorted Arrays29.6%Hard0.00371713094107092https://leetcode.com/problems/median-of-two-sorted-arrays
142Add Two Numbers33.9%Medium0.003640486182288058https://leetcode.com/problems/add-two-numbers
155Longest Palindromic Substring29.5%Medium0.0021771085723255794https://leetcode.com/problems/longest-palindromic-substring
1621Merge Two Sorted Lists53.5%Easy0.002158080146984904https://leetcode.com/problems/merge-two-sorted-lists
17151Reverse Words in a String21.9%Medium0.0015260771341435947https://leetcode.com/problems/reverse-words-in-a-string
1870Climbing Stairs47.8%Easy0.0014753073158671238https://leetcode.com/problems/climbing-stairs