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

19 lines
1.9 KiB
CSV

ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
525,Contiguous Array,42.8%,Medium,0.42990617361238165, https://leetcode.com/problems/contiguous-array
498,Diagonal Traverse,48.2%,Medium,0.32668133250056075, https://leetcode.com/problems/diagonal-traverse
855,Exam Room,43.1%,Medium,0.22345649138873985, https://leetcode.com/problems/exam-room
1053,Previous Permutation With One Swap,48.5%,Medium,0.20067069546215116, https://leetcode.com/problems/previous-permutation-with-one-swap
437,Path Sum III,47.2%,Medium,0.13327677772817573, https://leetcode.com/problems/path-sum-iii
1027,Longest Arithmetic Sequence,53.4%,Medium,0.11122563511022437, https://leetcode.com/problems/longest-arithmetic-sequence
780,Reaching Points,29.4%,Hard,0.1040197878075301, https://leetcode.com/problems/reaching-points
390,Elimination Game,44.5%,Medium,0.0922312242160336, https://leetcode.com/problems/elimination-game
1329,Sort the Matrix Diagonally,78.4%,Medium,0.08584868273025201, https://leetcode.com/problems/sort-the-matrix-diagonally
452,Minimum Number of Arrows to Burst Balloons,49.6%,Medium,0.06234705801852781, https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons
297,Serialize and Deserialize Binary Tree,47.5%,Hard,0.05889827677358506, https://leetcode.com/problems/serialize-and-deserialize-binary-tree
113,Path Sum II,46.7%,Medium,0.03698133452871584, https://leetcode.com/problems/path-sum-ii
253,Meeting Rooms II,45.7%,Medium,0.017208837680639542, https://leetcode.com/problems/meeting-rooms-ii
48,Rotate Image,56.7%,Medium,0.010933053508947611, https://leetcode.com/problems/rotate-image
380,Insert Delete GetRandom O(1),47.5%,Medium,0.00934149716911291, https://leetcode.com/problems/insert-delete-getrandom-o1
162,Find Peak Element,43.3%,Medium,0.006070742577979871, https://leetcode.com/problems/find-peak-element
560,Subarray Sum Equals K,43.9%,Medium,0.00407664649376343, https://leetcode.com/problems/subarray-sum-equals-k