LeetCode-Questions-CompanyWise/spotify_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
2286Walls and Gates54.5%Medium0.045906593198722395https://leetcode.com/problems/walls-and-gates
3383Ransom Note53.1%Easy0.039220713153281295https://leetcode.com/problems/ransom-note
4480Sliding Window Median37.2%Hard0.03373001037669306https://leetcode.com/problems/sliding-window-median
520Valid Parentheses39.0%Easy0.02782373445001039https://leetcode.com/problems/valid-parentheses
622Generate Parentheses62.7%Medium0.026949997964496694https://leetcode.com/problems/generate-parentheses
7784Letter Case Permutation64.6%Medium0.02026411791905559https://leetcode.com/problems/letter-case-permutation
8128Longest Consecutive Sequence45.1%Hard0.020252717433212362https://leetcode.com/problems/longest-consecutive-sequence
9146LRU Cache33.2%Medium0.01827577993873683https://leetcode.com/problems/lru-cache
10443String Compression41.3%Easy0.01390843004613198https://leetcode.com/problems/string-compression
11206Reverse Linked List62.5%Easy0.009326794511974934https://leetcode.com/problems/reverse-linked-list
12215Kth Largest Element in an Array55.4%Medium0.008759180089881562https://leetcode.com/problems/kth-largest-element-in-an-array
13412Fizz Buzz62.3%Easy0.007165921026143679https://leetcode.com/problems/fizz-buzz
14200Number of Islands46.8%Medium0.006490251382779317https://leetcode.com/problems/number-of-islands
153Longest Substring Without Repeating Characters30.4%Medium0.006208067119374334https://leetcode.com/problems/longest-substring-without-repeating-characters
16127Word Ladder29.6%Medium0.005979091056058075https://leetcode.com/problems/word-ladder
17347Top K Frequent Elements61.2%Medium0.0033396446491217604https://leetcode.com/problems/top-k-frequent-elements
1866Plus One43.0%Easy0.00326211347832938https://leetcode.com/problems/plus-one
191Two Sum45.6%Easy0.00184543512358731https://leetcode.com/problems/two-sum