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 @@
|
||||
236,Lowest Common Ancestor of a Binary Tree,45.7%,Medium,0.06122838444838759, https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
|
||||
437,Path Sum III,47.2%,Medium,0.04550116684579005, https://leetcode.com/problems/path-sum-iii
|
||||
443,String Compression,41.3%,Easy,0.029773949243192512, https://leetcode.com/problems/string-compression
|
||||
981,Time Based Key-Value Store,53.1%,Medium,0.02132276946882123, https://leetcode.com/problems/time-based-key-value-store
|
||||
146,LRU Cache,33.2%,Medium,0.017369086240613615, https://leetcode.com/problems/lru-cache
|
||||
127,Word Ladder,29.6%,Medium,0.012849976929025548, https://leetcode.com/problems/word-ladder
|
||||
273,Integer to English Words,27.1%,Hard,0.01153415324528653, https://leetcode.com/problems/integer-to-english-words
|
||||
387,First Unique Character in a String,53.4%,Easy,0.008959741371471904, https://leetcode.com/problems/first-unique-character-in-a-string
|
||||
20,Valid Parentheses,39.0%,Easy,0.004938010692392608, https://leetcode.com/problems/valid-parentheses
|
||||
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
|
||||
283,Move Zeroes,57.8%,Easy,0.002758622439079723, https://leetcode.com/problems/move-zeroes
|
||||
53,Maximum Subarray,46.5%,Easy,0.0020745819379855658, https://leetcode.com/problems/maximum-subarray
|
||||
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
|
||||
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0014852223137141987, https://leetcode.com/problems/longest-substring-without-repeating-characters
|
||||
ID,Title,Acceptance,Difficulty,Frequency,Leetcode Question Link
|
||||
236,Lowest Common Ancestor of a Binary Tree,45.7%,Medium,0.06122838444838759, https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
|
||||
437,Path Sum III,47.2%,Medium,0.04550116684579005, https://leetcode.com/problems/path-sum-iii
|
||||
443,String Compression,41.3%,Easy,0.029773949243192512, https://leetcode.com/problems/string-compression
|
||||
981,Time Based Key-Value Store,53.1%,Medium,0.02132276946882123, https://leetcode.com/problems/time-based-key-value-store
|
||||
146,LRU Cache,33.2%,Medium,0.017369086240613615, https://leetcode.com/problems/lru-cache
|
||||
127,Word Ladder,29.6%,Medium,0.012849976929025548, https://leetcode.com/problems/word-ladder
|
||||
273,Integer to English Words,27.1%,Hard,0.01153415324528653, https://leetcode.com/problems/integer-to-english-words
|
||||
387,First Unique Character in a String,53.4%,Easy,0.008959741371471904, https://leetcode.com/problems/first-unique-character-in-a-string
|
||||
20,Valid Parentheses,39.0%,Easy,0.004938010692392608, https://leetcode.com/problems/valid-parentheses
|
||||
139,Word Break,40.1%,Medium,0.003755167762323698, https://leetcode.com/problems/word-break
|
||||
283,Move Zeroes,57.8%,Easy,0.002758622439079723, https://leetcode.com/problems/move-zeroes
|
||||
53,Maximum Subarray,46.5%,Easy,0.0020745819379855658, https://leetcode.com/problems/maximum-subarray
|
||||
121,Best Time to Buy and Sell Stock,50.5%,Easy,0.0020383211296970956, https://leetcode.com/problems/best-time-to-buy-and-sell-stock
|
||||
3,Longest Substring Without Repeating Characters,30.4%,Medium,0.0014852223137141987, https://leetcode.com/problems/longest-substring-without-repeating-characters
|
||||
|
||||
|
Reference in New Issue
Block a user