Split string on whitespace in Python

I’m looking for the Python equivalent of String str = "many fancy word nhello thi"; String whiteSpaceRegex = "\s"; String[] words = str.split(whiteSpaceRegex); ["many", "fancy", "word", "hello", "hi"] Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat … Read more

How to make separator in pandas read_csv more flexible wrt whitespace, for irregular separators?

I need to create a data frame by reading in data from a file, using read_csv method. However, the separators are not very regular: some columns are separated by tabs (t), other are separated by spaces. Moreover, some columns can be separated by 2 or 3 or more spaces or even by a combination of spaces and tabs (for example 3 spaces, two tabs and then 1 space).