Fix Python – How to read file with space separated values in pandas

Question

Asked By – yemu

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

Now we will see solution for issue: How to read file with space separated values in pandas


Answer

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

This question is answered By – HYRY

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0