In Python, you can use pandas.read_csv() to read csv files. It returns a Pandas DataFrame.
You will learn how to use pandas to load csv files in several examples below. And I also have a tutorial for pandas.read_excel() if you are looking for that.
Use pandas.read_csv() with header
Import pandas module and call pandas.read_csv() with parameter filepath, sep, and header. It returns a pandas.DataFrame of the contents of the file.
| |
Import csv file with no header
With parameter header = None, read_csv() will return the DataFrame without header. In case, you need to skip the first row, use skiprows parameter.
| |
Open txt file with tab separated
The code example below is pretty self-explanatory.
| |
Additional reading: Read more about pd.read_csv() in the Pandas documentation.
Now you have learn from the examples above to use pandas.read_csv(). Have a great day!