mirror of
https://github.com/McSmog/LeetCode-Questions-CompanyWise.git
synced 2026-04-19 16:56:45 +00:00
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)
```
This commit is contained in:
committed by
GitHub
parent
0aeadbd612
commit
fb5f78b55e
@@ -1,14 +1,15 @@
|
||||
984,String Without AAA or BBB,37.7%,Medium,0.4954247677613364, https://leetcode.com/problems/string-without-aaa-or-bbb
|
||||
915,Partition Array into Disjoint Intervals,45.4%,Medium,0.37292635232139065, https://leetcode.com/problems/partition-array-into-disjoint-intervals
|
||||
983,Minimum Cost For Tickets,60.5%,Medium,0.26701398643191887, https://leetcode.com/problems/minimum-cost-for-tickets
|
||||
527,Word Abbreviation,54.3%,Hard,0.24362208265775043, https://leetcode.com/problems/word-abbreviation
|
||||
1017,Convert to Base -2,59.0%,Medium,0.17904823144898546, https://leetcode.com/problems/convert-to-base-2
|
||||
1253,Reconstruct a 2-Row Binary Matrix,40.4%,Medium,0.16098937604759944, https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix
|
||||
42,Trapping Rain Water,48.9%,Hard,0.038490960607653675, https://leetcode.com/problems/trapping-rain-water
|
||||
2,Add Two Numbers,33.9%,Medium,0.020491663368639005, https://leetcode.com/problems/add-two-numbers
|
||||
41,First Missing Positive,32.0%,Hard,0.014368063266920193, https://leetcode.com/problems/first-missing-positive
|
||||
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.00846879565300311, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
|
||||
234,Palindrome Linked List,39.3%,Easy,0.004533613114828982, https://leetcode.com/problems/palindrome-linked-list
|
||||
238,Product of Array Except Self,60.1%,Medium,0.003930436424724545, https://leetcode.com/problems/product-of-array-except-self
|
||||
215,Kth Largest Element in an Array,55.4%,Medium,0.003902443976931749, https://leetcode.com/problems/kth-largest-element-in-an-array
|
||||
1073,Adding Two Negabinary Numbers,34.2%,Medium,0, https://leetcode.com/problems/adding-two-negabinary-numbers
|
||||
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
||||
984,String Without AAA or BBB,37.7%,Medium,0.4954247677613364, https://leetcode.com/problems/string-without-aaa-or-bbb
|
||||
915,Partition Array into Disjoint Intervals,45.4%,Medium,0.37292635232139065, https://leetcode.com/problems/partition-array-into-disjoint-intervals
|
||||
983,Minimum Cost For Tickets,60.5%,Medium,0.26701398643191887, https://leetcode.com/problems/minimum-cost-for-tickets
|
||||
527,Word Abbreviation,54.3%,Hard,0.24362208265775043, https://leetcode.com/problems/word-abbreviation
|
||||
1017,Convert to Base -2,59.0%,Medium,0.17904823144898546, https://leetcode.com/problems/convert-to-base-2
|
||||
1253,Reconstruct a 2-Row Binary Matrix,40.4%,Medium,0.16098937604759944, https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix
|
||||
42,Trapping Rain Water,48.9%,Hard,0.038490960607653675, https://leetcode.com/problems/trapping-rain-water
|
||||
2,Add Two Numbers,33.9%,Medium,0.020491663368639005, https://leetcode.com/problems/add-two-numbers
|
||||
41,First Missing Positive,32.0%,Hard,0.014368063266920193, https://leetcode.com/problems/first-missing-positive
|
||||
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.00846879565300311, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
|
||||
234,Palindrome Linked List,39.3%,Easy,0.004533613114828982, https://leetcode.com/problems/palindrome-linked-list
|
||||
238,Product of Array Except Self,60.1%,Medium,0.003930436424724545, https://leetcode.com/problems/product-of-array-except-self
|
||||
215,Kth Largest Element in an Array,55.4%,Medium,0.003902443976931749, https://leetcode.com/problems/kth-largest-element-in-an-array
|
||||
1073,Adding Two Negabinary Numbers,34.2%,Medium,0, https://leetcode.com/problems/adding-two-negabinary-numbers
|
||||
|
||||
|
Reference in New Issue
Block a user