pj_0001_compare_col_csv
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import pathlib
import pandas as pd
print("please input the 1stfile to compare")
csv_from = input()
print("please input the compare column")
from_col = input()
print("please input the 2ndfile to compare")
csv_to = input()
print("please input the compare column")
to_col = input()
print(csv_from)
print(from_col)
print(csv_to)
print(to_col)
#check csv
def _compare_csv():
df_from = pd.read_csv(csv_from)
df_to = pd.read_csv(csv_to)
lcol_from = list(df_from[from_col])
lcol_to = list(df_to[to_col])
print("column size of 1st csv is:", len(lcol_from))
print("column size of 2nd csv is:", len(lcol_to))
s1 = set(lcol_from)
s2 = set(lcol_to)
ss1 = s1 - s2
ss2 = s2 - s1
print("1st csv - 2nd csv is",ss1)
print("2nd csv - 1st csv is",ss2)
# ex
print("get other col item?")
q1 = input()
if q1 == 'no':
return
print("get from col or to col?")
q2 = input()
print("give me a col name")
col_name = input()
if q2 == 'from':
lcol_other = list(df_from[col_name])
ss_other = ss1
lcol_ref = lcol_from
else:
lcol_other = list(df_to[col_name])
ss_other = ss2
lcol_ref = lcol_to
#ex for 1st - 2nd
print("ex col value is:")
lout = []
for i in ss_other:
lout.append(lcol_other[lcol_ref.index(i)])
print("other col items is:", lout)
print("for un_repetition", set(lout))
if __name__ == '__main__':
_compare_csv()
最新文章
- Linux 命令快捷键
- DOCTYPE声明的作用是什么?严格模式与混杂模式如何区分?
- 每日Scrum(9)
- Web Worker
- Js 中json简单处理
- Python之练习Demo
- python 单元测试
- WCF 接收我服务的 HTTP 响应时发生错误
- gridview两列数据的互换
- tomcat源代码Catalina
- 监听 window.open 打开的窗口关闭并回调
- Objective-C 和 Swift 混编项目的小 Tips(一)
- 通过SMTP发送邮件的Python代码
- Beta冲刺Day3
- Python内置函数(55)——globals
- HBase replication
- java基础-String不可变的好处
- MySQL之记录相关操作
- 【C#复习总结】dynamic
- bzoj1233 单调队列优化dp