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)

```
This commit is contained in:
Krishna Kumar Dey
2023-04-01 11:07:49 +05:30
committed by GitHub
parent 0aeadbd612
commit fb5f78b55e
534 changed files with 20291 additions and 19757 deletions

View File

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