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

18 lines
1.7 KiB
CSV

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