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

17 lines
1.7 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
1283,Find the Smallest Divisor Given a Threshold,47.6%,Medium,0.1369289189470806, https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold
443,String Compression,41.3%,Easy,0.08391368024915737, https://leetcode.com/problems/string-compression
724,Find Pivot Index,44.0%,Easy,0.03089844155123413, https://leetcode.com/problems/find-pivot-index
33,Search in Rotated Sorted Array,34.5%,Medium,0.0287009496170278, https://leetcode.com/problems/search-in-rotated-sorted-array
146,LRU Cache,33.2%,Medium,0.01827577993873683, https://leetcode.com/problems/lru-cache
134,Gas Station,38.5%,Medium,0.01352742981715631, https://leetcode.com/problems/gas-station
973,K Closest Points to Origin,63.8%,Medium,0.012944233661064114, https://leetcode.com/problems/k-closest-points-to-origin
739,Daily Temperatures,63.3%,Medium,0.010032690121814417, https://leetcode.com/problems/daily-temperatures
198,House Robber,42.0%,Easy,0.008434914115059812, https://leetcode.com/problems/house-robber
200,Number of Islands,46.8%,Medium,0.006490251382779317, https://leetcode.com/problems/number-of-islands
20,Valid Parentheses,39.0%,Easy,0.005168860577665306, https://leetcode.com/problems/valid-parentheses
1,Two Sum,45.6%,Easy,0.0051178232035212715, https://leetcode.com/problems/two-sum
53,Maximum Subarray,46.5%,Easy,0.004869349014182134, https://leetcode.com/problems/maximum-subarray
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0047725193990346675, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0015556336509412823, https://leetcode.com/problems/longest-substring-without-repeating-characters