Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the read_csv() function from pandas to convert data separated by pipes into a dataframe. Simply specify the sep parameter as '|'. Here's an example:

import pandas as pd

# sample data separated by pipes
data = 'Name|Age|Gender\nJohn|25|M\nMary|30|F\nBob|20|M'

# convert data to dataframe
df = pd.read_csv(pd.compat.StringIO(data), sep='|')

print(df)

Output:

   Name  Age Gender
0  John   25      M
1  Mary   30      F
2   Bob   20      M