10 examples of 'line.strip().split()' in Python

Every line of 'line.strip().split()' 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
21def splitter(line):
22 return line.split()
158def splitLines(line) :
159
160 global sedanCount
161 global hatchbackCount
162
163 #Use broadcast variable to do comparison and set accumulator
164 if sedanText.value in line:
165 sedanCount +=1
166 if hatchbackText.value in line:
167 hatchbackCount +=1
168
169 return line.split(",")
31@staticmethod
32def _cleverSplit(line):
33 # Split tokens (keeping quoted strings intact).
34
35 PATTERN = re.compile(r"""(
36 \s | \] | \[ | \, | = | # Match whitespace, braces, comma, =
37 ".*?[^\\]" | '.*?[^\\]' # Match single/double-quotes.
38 )""", re.X)
39 return [p for p in PATTERN.split(line) if p.strip()]
38def SplitLine(line):
39 """Splits the line controls off of a line.
40
41 >>> SplitLine(' > This is my line (2s)')
42 (' > This is my line', '2s')
43 >>> SplitLine(' > This one has no controls')
44 (' > This one has no controls', None)
45 >>> SplitLine(' > This has an escaped control (&see)')
46 (' > This has an escaped control (see)', None)
47 >>> SplitLine(' world (20,)')
48 (' world', '20,')
49
50 Args:
51 line: The line to split
52 Returns:
53 (line, control string)
54 """
55 match = REGEX.CONTROL_BLOCK.match(line)
56 if match:
57 return match.groups()
58 unescape = REGEX.ESCAPED_BLOCK.match(line)
59 if unescape:
60 return ('%s (%s)' % unescape.groups(), None)
61 return (line, None)
482@staticmethod
483def splitline(line):
484 """
485 Splits a line into pieces based on common delimiters
486 :param line: A single line of text
487 :return: list of values
488 """
489 # Initial try for CSV (split on ,)
490 toks = line.split(',')
491 # Now try SCSV (split on ;)
492 if len(toks) < 2:
493 toks = line.split(';')
494 # Now go for whitespace
495 if len(toks) < 2:
496 toks = line.split()
497 return toks
50def split_words(line):
51 def unquote(x):
52 if x and x[0] == '"':
53 return x[1:-1]
54 else:
55 return x
56
57 if '"' in line:
58 # handle quoted arguments
59 return [ unquote(x) for x in re_word.findall(line) ]
60 else:
61 # shortcut for the bulk of cases
62 return line.split()
153def _parse_line(sep, line):
154 """
155 parse a grub commands/config with format: cmd{sep}opts
156 Returns: (name, value): value can be None
157 """
158 strs = line.split(sep, 1)
159 return (strs[0].strip(), None) if len(strs) == 1 else (strs[0].strip(), strs[1].strip())
37def split(line):
38 """
39 Operator function for splitting a line with csv module
40 """
41 reader = csv.reader(StringIO(line))
42 return reader.next()
126def split_string(input_string):
127 '''Split a string to a list and strip it
128 :param input_string: A string that contains semicolons as separators.
129 '''
130 string_splitted = input_string.split(';')
131 # Remove whitespace at the beginning and end of each string
132 strings_striped = [string.strip() for string in string_splitted]
133 return strings_striped
40def default_split(line):
41 return line.split()

Related snippets