mirror of
https://github.com/McSmog/LeetCode-Questions-CompanyWise.git
synced 2026-04-19 16:56:45 +00:00
## 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)
```
24 lines
2.4 KiB
CSV
24 lines
2.4 KiB
CSV
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
|
271,Encode and Decode Strings,31.5%,Medium,0.456074830875999, https://leetcode.com/problems/encode-and-decode-strings
|
|
336,Palindrome Pairs,33.7%,Hard,0.3591927799310734, https://leetcode.com/problems/palindrome-pairs
|
|
969,Pancake Sorting,67.5%,Medium,0.27343004974457946, https://leetcode.com/problems/pancake-sorting
|
|
999,Available Captures for Rook,66.7%,Easy,0.24587963229494916, https://leetcode.com/problems/available-captures-for-rook
|
|
72,Edit Distance,44.8%,Hard,0.14935692774322157, https://leetcode.com/problems/edit-distance
|
|
91,Decode Ways,24.7%,Medium,0.05247487679829598, https://leetcode.com/problems/decode-ways
|
|
127,Word Ladder,29.6%,Medium,0.03679590970204585, https://leetcode.com/problems/word-ladder
|
|
165,Compare Version Numbers,27.4%,Medium,0.0351873674509732, https://leetcode.com/problems/compare-version-numbers
|
|
824,Goat Latin,63.4%,Easy,0.0317991816929387, https://leetcode.com/problems/goat-latin
|
|
415,Add Strings,47.5%,Easy,0.030009753867991852, https://leetcode.com/problems/add-strings
|
|
277,Find the Celebrity,41.8%,Medium,0.02969780239174205, https://leetcode.com/problems/find-the-celebrity
|
|
273,Integer to English Words,27.1%,Hard,0.026980053764546055, https://leetcode.com/problems/integer-to-english-words
|
|
981,Time Based Key-Value Store,53.1%,Medium,0.02226024024151985, https://leetcode.com/problems/time-based-key-value-store
|
|
332,Reconstruct Itinerary,36.7%,Medium,0.013755375068485329, https://leetcode.com/problems/reconstruct-itinerary
|
|
269,Alien Dictionary,33.3%,Hard,0.012730916694039954, https://leetcode.com/problems/alien-dictionary
|
|
208,Implement Trie (Prefix Tree),49.4%,Medium,0.009105457856626612, https://leetcode.com/problems/implement-trie-prefix-tree
|
|
39,Combination Sum,56.1%,Medium,0.005715934396440999, https://leetcode.com/problems/combination-sum
|
|
105,Construct Binary Tree from Preorder and Inorder Traversal,48.8%,Medium,0.005628268691614718, https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal
|
|
15,3Sum,26.8%,Medium,0.004940992758742591, https://leetcode.com/problems/3sum
|
|
17,Letter Combinations of a Phone Number,46.8%,Medium,0.0044018999217624675, https://leetcode.com/problems/letter-combinations-of-a-phone-number
|
|
139,Word Break,40.1%,Medium,0.003894465052690167, https://leetcode.com/problems/word-break
|
|
200,Number of Islands,46.8%,Medium,0.0028897578265903614, https://leetcode.com/problems/number-of-islands
|