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

23 lines
2.3 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
755,Pour Water,43.3%,Medium,1.6549959634129805, https://leetcode.com/problems/pour-water
1166,Design File System,56.8%,Medium,1.578042968988746, https://leetcode.com/problems/design-file-system
336,Palindrome Pairs,33.7%,Hard,1.3086247857193076, https://leetcode.com/problems/palindrome-pairs
166,Fraction to Recurring Decimal,21.6%,Medium,1.110416810228655, https://leetcode.com/problems/fraction-to-recurring-decimal
875,Koko Eating Bananas,52.1%,Medium,0.8409986269592165, https://leetcode.com/problems/koko-eating-bananas
773,Sliding Puzzle,59.3%,Hard,0.6810258200276005, https://leetcode.com/problems/sliding-puzzle
864,Shortest Path to Get All Keys,40.1%,Hard,0.6061358035703156, https://leetcode.com/problems/shortest-path-to-get-all-keys
787,Cheapest Flights Within K Stops,39.3%,Medium,0.5212226928497461, https://leetcode.com/problems/cheapest-flights-within-k-stops
269,Alien Dictionary,33.3%,Hard,0.48723106280473205, https://leetcode.com/problems/alien-dictionary
251,Flatten 2D Vector,45.7%,Medium,0.4808790962829651, https://leetcode.com/problems/flatten-2d-vector
1257,Smallest Common Region,58.8%,Medium,0.2561688067457042, https://leetcode.com/problems/smallest-common-region
68,Text Justification,27.7%,Hard,0.16143214434637243, https://leetcode.com/problems/text-justification
1235,Maximum Profit in Job Scheduling,44.0%,Hard,0.1532629744871177, https://leetcode.com/problems/maximum-profit-in-job-scheduling
39,Combination Sum,56.1%,Medium,0.1339254107186325, https://leetcode.com/problems/combination-sum
324,Wiggle Sort II,29.9%,Medium,0.11122563511022437, https://leetcode.com/problems/wiggle-sort-ii
759,Employee Free Time,66.2%,Hard,0.10623186692973738, https://leetcode.com/problems/employee-free-time
280,Wiggle Sort,63.8%,Medium,0.04362742017962607, https://leetcode.com/problems/wiggle-sort
322,Coin Change,35.5%,Medium,0.024924029676386045, https://leetcode.com/problems/coin-change
341,Flatten Nested List Iterator,52.9%,Medium,0.019980684690483426, https://leetcode.com/problems/flatten-nested-list-iterator
236,Lowest Common Ancestor of a Binary Tree,45.7%,Medium,0.004714210262726446, https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
42,Trapping Rain Water,48.9%,Hard,0.004350670338744988, https://leetcode.com/problems/trapping-rain-water