How to read file with space separated values in pandas

I try to read the file into pandas. The file has values separated by space, but with different number of spaces I tried:

pd.read_csv('file.csv', delimiter=' ')

but it doesn't work


add delim_whitespace=True argument, it's faster than regex.


you can use regex as the delimiter:

pd.read_csv("whitespace.csv", header=None, delimiter=r"\s+")