使用python讀取文件數(shù)據(jù)的方法:1.新建python項(xiàng)目;2.導(dǎo)入pandas模塊;3.使用pd.read方法讀取文件數(shù)據(jù);
具體步驟如下:
1.首先,打開python,并新建一個(gè)python項(xiàng)目;
2.python項(xiàng)目創(chuàng)建好后,在項(xiàng)目中使用import方法導(dǎo)入pandas模塊;
import pandas as pd
3.pandas模塊導(dǎo)入后,使用pd.read方法即可讀取文件數(shù)據(jù);
1)讀取txt文件數(shù)據(jù)
file = pd.read_txt('C:\\test_code.txt',sep = '\t',encoding = 'utf-8')
2)讀取csv文件數(shù)據(jù)
file = pd.read_csv('C:\\test.csv',sep = ',',encoding = 'utf-8')
3)讀取sas文件數(shù)據(jù)
file = pd.read_sas('G:\\class.sas',encoding='utf8')