# 读取csv文件 (数据以逗号分割)
import csv
csvfile = open('data.csv', 'rb')
reader = csv.reader(csvfile) # read接收文件对象,返回数据列表
reader1 = csv.DictReader(csvfile) # 返回数据字典
for row in reader:
print(row)
# json文件(数据传输,网站运用, 形式如字典 )
import json
json_data = open('C:\\Users\\admin\\Desktop\\python数据处理(数据)data-wrangling-master\\data-wrangling-master\\data\\chp3\\data-text.json').read()
data = json.loads(json_data) # loads接收字符串
for item in data:
print(item)
# 导入xml文件
from xml.etree import ElementTree as ET
tree = ET.parse(r'C:\Users\admin\Desktop\python数据处理(数据)data-wrangling-master\data-wrangling-master\data\chp3\data-text.xml')
root = tree.getroot()
data = root.find('Data')
print(list(data))