
If file contains no header row, then you shouldĮxplicitly pass header=None. Line of data rather than the first line of the file. Lines if skip_blank_lines=True, so header=0 denotes the first Note that this parameter ignores commented lines and empty That are not specified will be skipped (e.g. The header can be a list of ints that specify row locationsįor a MultiIndex on the columns e.g. Explicitly pass header=0 to be able to replace Passed explicitly then the behavior is identical to Passed the behavior is identical to header=0 and column namesĪre inferred from the first line of the file, if column names are Default behavior is to infer the column names: if no names are Row number(s) to use as the column names, and the start of theĭata. Column and index locations and names # header int or list of ints, default 'infer' If this option is set to True, nothing should be passed in for theĭelimiter parameter. Specifies whether or not whitespace (e.g. delimiter str, default NoneĪlternative argument name for sep. Note that regexĭelimiters are prone to ignoring quoted data. Will also force the use of the Python parsing engine. In addition, separators longer than 1 character andĭifferent from '\s+' will be interpreted as regular expressions and

Used and automatically detect the separator by Python’s builtin sniffer tool,Ĭsv.Sniffer. The separator, but the Python parsing engine can, meaning the latter will be If sep is None, the C engine cannot automatically detect sep str, defaults to ',' for read_csv(), \t for read_table()ĭelimiter to use. Locations), or any object with a read() method (such as an open file or Or py:py._), URL (including http, ftp, and S3 Read_csv() accepts the following common arguments: Basic # filepath_or_buffer variousĮither a path to a file (a str, pathlib.Path, See the cookbook for some advanced strategies. The workhorse function for reading text files (a.k.a.

With from io import StringIO for Python 3.

Here is an informal performance comparison for some of these IO methods.įor examples that use the StringIO class, make sure you import it Below is a table containing available readers and Writer functions are object methods that are accessed likeĭataFrame.to_csv(). Pandas.read_csv() that generally return a pandas object. The pandas I/O API is a set of top level reader functions accessed like
