目录
一、前言
通过列表、字典方法创建表格,并存储;
二、知识点
1、
语法:
pandas.DataFrame(List/dictionary)
其中,
- pandas是支持DataFrame数据结构的模块。
- DataFrame是将字典转换为数据框架的数据结构。
- dictionary是输入列表或字典
三、实现代码
import pandas as pd
import sys
import os
def Test_main():
test_df_path= r'D:/test_df.csv'
test_list = []
#从arxml文件读取name,path
swc_name = 'a1'
port_name = 'b1'
interfece_name = 'c1'
dict_temp = {"SWC Name": swc_name, "Port Name": port_name ,'Interface Name' : interfece_name }
test_list.append(dict_temp)
#print(test_list)
##再次从arxml文件读取name,path
swc_name = 'a2'
port_name = 'b2'
interfece_name = 'c2'
dict_temp = {"SWC Name": swc_name, "Port Name": port_name ,'Interface Name' : interfece_name }
test_list.append(dict_temp)
#print(port_list)
test_df = pd.DataFrame(test_list)
test_df .to_csv(test_df_path , index= False)
print(test_df)
if __name__ == "__main__":
Test_main()
四、输出打印结果
五 、表格生成