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()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现