6 examples of 'python split on comma' in Python

Every line of 'python split on comma' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
74def split_comma_semicolon_lists(s, dtype=None):
75 """TODO
76 Parameters
77 ----------
78 s
79 Input string
80 dtype: optional
81 Data type to impose upon values
82 """
83 res = []
84 for x in s.split(";"):
85 if not ':' in x:
86 raise ValueError("Each entry must be in the form key:values,"
87 " e.g. 'targets:rest'")
88 key, s_values = x.split(':', 1)
89 values = s_values.split(',')
90 if dtype is not None:
91 values = [dtype(v) for v in values]
92 res.append((key, values))
93 return res
118def convert_list_comma(s):
119 """
120 Return a list object from the <s>.
121 Consider <s> is comma delimited.
122 """
123 if s is None:
124 return []
125 if isinstance(s, list):
126 return s
127 return [word for word in re.split(r"\s*,\s*", s.strip()) if word != ""]</s></s>
285def rsplit(a_string, sep=None, maxsplit=None):
286 parts = a_string.split(sep)
287 if maxsplit is None or len(parts) &lt;= maxsplit:
288 return parts
289 maxsplit_index = len(parts) - maxsplit
290 non_splitted_part = sep.join(parts[:maxsplit_index])
291 splitted = parts[maxsplit_index:]
292 return [non_splitted_part] + splitted
113def split(string, char):
114 """ Split a string with a char and return always two parts"""
115 string_list = string.split(char)
116 if len(string_list) == 1:
117 return None, None
118 return char.join(string_list[:-1]), string_list[-1]
263def multi_split(s, seps):
264 res = [s]
265 for sep in seps:
266 s, res = res, []
267 for seq in s:
268 res += seq.split(sep)
269 return res
177def _split_by_comma(self, comma_delimited_text):
178 """Returns a list of the words in the comma delimited text."""
179 return comma_delimited_text.replace(" ", "").split(",")

Related snippets