0
Q:

how to read a csv file in python using pandas

# Import pandas 
import pandas as pd 
  
# Read csv file  
table = pd.read_csv("filename.csv") 
# Print it out if you want to...
print(table)
5
import csv

with open('employee_birthday.txt') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    for row in csv_reader:
        if line_count == 0:
            print(f'Column names are {", ".join(row)}')
            line_count += 1
        else:
            print(f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.')
            line_count += 1
    print(f'Processed {line_count} lines.')
7
import pandas as pd
df=pd.read_csv('the_file.csv')
3
you should be in the same dir as .py file 

df = pd.read_csv('your_file_name.csv')
1
import pandas as pd
import io
import requests
url="https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv"
s=requests.get(url).content
c=pd.read_csv(io.StringIO(s.decode('utf-8')))
0

New to Communities?

Join the community