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

1IDTitleAcceptanceDifficultyFrequencyLeetcode Question Link
21283Find the Smallest Divisor Given a Threshold47.6%Medium0.1369289189470806https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold
3443String Compression41.3%Easy0.08391368024915737https://leetcode.com/problems/string-compression
4724Find Pivot Index44.0%Easy0.03089844155123413https://leetcode.com/problems/find-pivot-index
533Search in Rotated Sorted Array34.5%Medium0.0287009496170278https://leetcode.com/problems/search-in-rotated-sorted-array
6146LRU Cache33.2%Medium0.01827577993873683https://leetcode.com/problems/lru-cache
7134Gas Station38.5%Medium0.01352742981715631https://leetcode.com/problems/gas-station
8973K Closest Points to Origin63.8%Medium0.012944233661064114https://leetcode.com/problems/k-closest-points-to-origin
9739Daily Temperatures63.3%Medium0.010032690121814417https://leetcode.com/problems/daily-temperatures
10198House Robber42.0%Easy0.008434914115059812https://leetcode.com/problems/house-robber
11200Number of Islands46.8%Medium0.006490251382779317https://leetcode.com/problems/number-of-islands
1220Valid Parentheses39.0%Easy0.005168860577665306https://leetcode.com/problems/valid-parentheses
131Two Sum45.6%Easy0.0051178232035212715https://leetcode.com/problems/two-sum
1453Maximum Subarray46.5%Easy0.004869349014182134https://leetcode.com/problems/maximum-subarray
15121Best Time to Buy and Sell Stock50.5%Easy0.0047725193990346675https://leetcode.com/problems/best-time-to-buy-and-sell-stock
163Longest Substring Without Repeating Characters30.4%Medium0.0015556336509412823https://leetcode.com/problems/longest-substring-without-repeating-characters