pandas Reading files into pandas DataFrame Read CSV File


Example

Data with header, separated by semicolons instead of commas

file: table.csv

index;name;occupation
1;Alice;Saleswoman
2;Bob;Engineer
3;Charlie;Janitor

code:

import pandas as pd
pd.read_csv('table.csv', sep=';', index_col=0)

output:

          name occupation
index
1        Alice   Salesman
2          Bob   Engineer
3      Charlie    Janitor

Table without row names or index and commas as separators

file: table.csv

Alice,Saleswoman
Bob,Engineer
Charlie,Janitor

code:

import pandas as pd 
pd.read_csv('table.csv', names=['name','occupation'])

output:

      name occupation
0    Alice   Salesman
1      Bob   Engineer
2  Charlie    Janitor

further clarification can be found in the read_csv documentation page