How to read a CSV file to a Dataframe with custom delimiter in Pandas?

How to read a CSV file to a Dataframe with custom delimiter in Pandas?

To read a CSV file with a custom delimiter into a DataFrame using the pandas library, you can use the read_csv() function and specify the delimiter or sep parameter.

Here's how you can do it:

import pandas as pd # Using delimiter parameter (both are equivalent) df = pd.read_csv('your_file_path.csv', delimiter=';') # Using sep parameter (alternative way) df = pd.read_csv('your_file_path.csv', sep=';') print(df.head()) 

In the above example, replace 'your_file_path.csv' with the path to your CSV file and ';' with the desired delimiter.

The delimiter and sep parameters are interchangeable, so you can use whichever one you prefer.


More Tags

picamera metadata uipickerview namevaluecollection removeall pandas-datareader django-manage.py diacritics shrink non-english

More Programming Guides

Other Guides

More Programming Examples