Ben Chuanlong Du's Blog

It is never too late to learn.

Read Text File into a pandas DataFrame

Advanced Options

  1. The argument sep supports regular expression! For example,

     :::python
     df = pd.read_csv(file, sep+" +")

nrows: control the number of rows to read skiprows, skip blank lines (the default behavior)

namesarray-like, optional List of column names to use. If the file contains a header row, then you should explicitly pass header=0 to override the column names. Duplicates in this list are not allowed.