Question #5856   Submitted by Answiki on 02/04/2022 at 11:47:05 AM UTC

In Python / Pandas, how to specify the separator with read_csv()?

Answer   Submitted by Answiki on 02/04/2022 at 11:54:15 AM UTC

In Python / Pandas, one of the optional parameters of read_csv() is sep (a shortened name for separator). This sep parameter tells the interpreter, which delimiter is used in the csv file. For example :


Here are some examples:

import pandas as pd

# Load comma separated csv file (default value for parameter sep)
data = pd.read_csv("filename.csv", sep = ',') 

# Load semi-comma separated csv file
data = pd.read_csv("filename.csv", sep = ';') 

# Load tabulation separated csv file (or tsv file)
data = pd.read_csv("filename.csv", sep = '\t') 

4 events in history
Answer by Answiki on 02/04/2022 at 11:54:15 AM

In Python / Pandas, one of the optional parameters of read_csv() is sep (a shortened name for separator). This sep parameter tells the interpreter, which delimiter is used in the csv file. For example :


Here are some examples:

import pandas as pd

# Load comma separated csv file (default value for parameter sep)
data = pd.read_csv("filename.csv", sep = ',') 

# Load semi-comma separated csv file
data = pd.read_csv("filename.csv", sep = ';') 

# Load tabulation separated csv file (or tsv file)
data = pd.read_csv("filename.csv", sep = '\t') 

Answer by Answiki on 02/04/2022 at 11:53:31 AM

In Python / Pandas, one of the optional parameters of read_csv() is sep (a shortened name for separator). This sep parameter tells the interpreter, which delimiter is used in the csv file. For example :


Here are some examples:


import pandas as pd

# Load comma separated csv file
data = pd.read_csv("filename.csv", sep = ',') 

# Load semi-comma separated csv file
data = pd.read_csv("filename.csv", sep = ';') 

# Load tabulation separated csv file (or tsv file)
data = pd.read_csv("filename.csv", sep = '\t') 

Answer by Answiki on 02/04/2022 at 11:52:48 AM

In Python / Pandas, one of the optional parameters of read_csv() is sep (a shortened name for separator). This sep parameter tells the interpreter, which delimiter is used in the csv file. For example :


Here are some examples:


import pandas as pd

# Load semi-comma separated csv file
data = pd.read_csv("filename.csv", sep = ';') 

# Load tabulation separated csv file (or tsv file)
data = pd.read_csv("filename.csv", sep = '\t') 

Question by Answiki 02/04/2022 at 11:47:05 AM
In Python / Pandas, how to specify the separator with read_csv()?
# ID Query URL Count

Icons proudly provided by Friconix.