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

18 lines
1.7 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
149,Max Points on a Line,16.9%,Hard,0.08243941611799847, https://leetcode.com/problems/max-points-on-a-line
274,H-Index,36.1%,Medium,0.0632254597089662, https://leetcode.com/problems/h-index
1213,Intersection of Three Sorted Arrays,78.9%,Easy,0.04401150329993394, https://leetcode.com/problems/intersection-of-three-sorted-arrays
692,Top K Frequent Words,51.8%,Medium,0.0439052078041538, https://leetcode.com/problems/top-k-frequent-words
1002,Find Common Characters,67.7%,Easy,0.033176651317732786, https://leetcode.com/problems/find-common-characters
65,Valid Number,15.3%,Hard,0.02168106606132404, https://leetcode.com/problems/valid-number
384,Shuffle an Array,52.8%,Medium,0.014706147389695468, https://leetcode.com/problems/shuffle-an-array
528,Random Pick with Weight,43.9%,Medium,0.014383563329954094, https://leetcode.com/problems/random-pick-with-weight
146,LRU Cache,33.2%,Medium,0.009807205116964715, https://leetcode.com/problems/lru-cache
33,Search in Rotated Sorted Array,34.5%,Medium,0.006961661779487692, https://leetcode.com/problems/search-in-rotated-sorted-array
73,Set Matrix Zeroes,43.1%,Medium,0.006699070439072842, https://leetcode.com/problems/set-matrix-zeroes
98,Validate Binary Search Tree,27.8%,Medium,0.0063060747091605324, https://leetcode.com/problems/validate-binary-search-tree
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
101,Symmetric Tree,46.8%,Easy,0.0032666423495169026, https://leetcode.com/problems/symmetric-tree
206,Reverse Linked List,62.5%,Easy,0.002231770161393673, https://leetcode.com/problems/reverse-linked-list
70,Climbing Stairs,47.8%,Easy,0.0014753073158671238, https://leetcode.com/problems/climbing-stairs