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

14 lines
1.4 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
25,Reverse Nodes in k-Group,42.1%,Hard,0.05055437541222425, https://leetcode.com/problems/reverse-nodes-in-k-group
76,Minimum Window Substring,34.6%,Hard,0.04336436867416216, https://leetcode.com/problems/minimum-window-substring
845,Longest Mountain in Array,37.2%,Medium,0.03578987502740307, https://leetcode.com/problems/longest-mountain-in-array
269,Alien Dictionary,33.3%,Hard,0.027110094009475887, https://leetcode.com/problems/alien-dictionary
166,Fraction to Recurring Decimal,21.6%,Medium,0.019305618894153366, https://leetcode.com/problems/fraction-to-recurring-decimal
207,Course Schedule,43.1%,Medium,0.010625837876226181, https://leetcode.com/problems/course-schedule
23,Merge k Sorted Lists,40.2%,Hard,0.008699909875545938, https://leetcode.com/problems/merge-k-sorted-lists
127,Word Ladder,29.6%,Medium,0.005731495844689608, https://leetcode.com/problems/word-ladder
56,Merge Intervals,39.3%,Medium,0.0033129067901687907, https://leetcode.com/problems/merge-intervals
200,Number of Islands,46.8%,Medium,0.002765297303115152, https://leetcode.com/problems/number-of-islands
283,Move Zeroes,57.8%,Easy,0.002758622439079723, https://leetcode.com/problems/move-zeroes
26,Remove Duplicates from Sorted Array,45.1%,Easy,0.0018681118827202508, https://leetcode.com/problems/remove-duplicates-from-sorted-array