Files
LeetCode-Questions-CompanyWise/visa_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

16 lines
1.6 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
761,Special Binary String,54.7%,Hard,0.09348775380846833, https://leetcode.com/problems/special-binary-string
362,Design Hit Counter,63.7%,Medium,0.05622967649867821, https://leetcode.com/problems/design-hit-counter
1353,Maximum Number of Events That Can Be Attended,30.5%,Medium,0.05428741283782842, https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended
42,Trapping Rain Water,48.9%,Hard,0.05203424501747888, https://leetcode.com/problems/trapping-rain-water
54,Spiral Matrix,34.1%,Medium,0.014776167707688753, https://leetcode.com/problems/spiral-matrix
76,Minimum Window Substring,34.6%,Hard,0.013966707481708198, https://leetcode.com/problems/minimum-window-substring
380,Insert Delete GetRandom O(1),47.5%,Medium,0.009820849864094454, https://leetcode.com/problems/insert-delete-getrandom-o1
253,Meeting Rooms II,45.7%,Medium,0.008079219870546493, https://leetcode.com/problems/meeting-rooms-ii
98,Validate Binary Search Tree,27.8%,Medium,0.006611351489350257, https://leetcode.com/problems/validate-binary-search-tree
15,3Sum,26.8%,Medium,0.004940992758742591, https://leetcode.com/problems/3sum
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0047725193990346675, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
1,Two Sum,45.6%,Easy,0.003278422738041615, https://leetcode.com/problems/two-sum
206,Reverse Linked List,62.5%,Easy,0.0023398665252948926, https://leetcode.com/problems/reverse-linked-list
20,Valid Parentheses,39.0%,Easy,0.0023005704055949323, https://leetcode.com/problems/valid-parentheses