Skip to content

Commit bce0e50

Browse files
authored
Create processing-form.py
1 parent 41e138e commit bce0e50

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

processing-form.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from typing import (
2+
List,
3+
)
4+
5+
class Solution:
6+
"""
7+
@param a: the csv file a
8+
@return: return the processed file
9+
"""
10+
def processing_file(self, a: List[str]) -> List[str]:
11+
# Write your code here
12+
ret = []
13+
rows = len(a)
14+
ls = []
15+
for i in range(rows):
16+
words = a[i].split(',')
17+
for i in range(len(words)):
18+
if i >= len(ls):
19+
ls.append(len(words[i]))
20+
if len(words[i]) > ls[i]:
21+
ls[i] = len(words[i])
22+
for i in range(rows):
23+
s = []
24+
words = a[i].split(',')
25+
for i in range(len(words)):
26+
w = words[i]
27+
s.append(' ' * (ls[i] - len(w)) + w)
28+
ret.append(','.join(s))
29+
return ret
30+
31+
# medium: https://www.lintcode.com/problem/1618/

0 commit comments

Comments
 (0)