How can I tell Pandas read_csv to use multiple whitespaces as separators but not single whitespaces? How can I tell Pandas read_csv to use multiple whitespaces as separators but not single whitespaces? pandas pandas

How can I tell Pandas read_csv to use multiple whitespaces as separators but not single whitespaces?


With specific regex pattern for sep= option:

df = pd.read_csv(sep='\s{2,}')
  • \s{2,} - quantifier, matches any whitespace character between 2 and unlimited times, as many times as possible


another option that I actually use, which saves me some shift keypresses:

df = pd.read_csv('file.csv', sep='\s\s+')