#!/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()

pj_0001_compare_col_csv的更多相关文章

随机推荐

  1. 视觉十四讲:第六讲_g2o图优化

    g2o是一个基于图优化的库,图优化是把优化问题表现为一种图的方式.一个图由若干个顶点和边组成. 顶点表示优化变量,边表示误差项. g2o的使用步骤: 1.定义顶点和边的类型: 2.构建图: 3.选择优 ...

  2. js实现替换对象(json)格式的键名

    某些场景下,我们拿到的键名与预期的键名不符,这个时候就需要替换键名来得到我们想要的内容 let obj = [ { id:1, title:'zs' }, { id:2, title:'ls' } ] ...

  3. JZOJ 4496. 【GDSOI 2016】第一题 互补约数

    \(\text{Problem}\) 求 \[\sum_{i=1}^n \sum_{d|n} \gcd(d, \frac{i}{d}) \] 有 \(n \le 10^{11}\) \(\text{A ...

  4. 代码随想录算法训练营day24 | leetcode 77. 组合

    基础知识 回溯法解决的问题都可以抽象为树形结构,集合的大小就构成了树的宽度,递归的深度构成的树的深度 void backtracking(参数) { if (终止条件) { 存放结果; return; ...

  5. net core 添加cors,解决跨域问题

    ConfigureServices //允许跨域 services.AddCors(options => { options.AddPolicy("any", builder ...

  6. 28.yield return 语法

    一.yield return 该语句可以实现在 foreach 循环中,在其他方法边遍历边输出.如下: class Program { private List<int> list = n ...

  7. Docker中使用Nginx镜像配置HTTPS和HTTP强制使用HTTPS访问(4)

    一.前言 上一文章当中说了Docker-Compose管理镜像和容器,本文章介绍使用Docker中Nginx镜像,使用的工具和ubuntu版本在ASP.NET CORE部署在Docker容器中已详细说 ...

  8. 如何简化跨网络安全域的文件发送流程,大幅降低IT人员工作量?

    为什么要做安全域的隔离? 随着企业数字化转型的逐步深入,企业投入了大量资源进行信息系统建设,信息化程度日益提升.在这一过程中,企业也越来越重视核心数据资产的保护,数据资产的安全防护成为企业面临的重大挑 ...

  9. VUE学习-插槽

    插槽 匿名插槽 子组件设置匿名插槽 <script type="text/x-template" id="custom-comp"> <div ...

  10. python代码编译总结-用于代码加密

    基于一个自废武功式的决定,服务需要做成标准件在客户服务器上运行,因此调研了python代码加密的相关内容.py的代码混淆没有被采用,而是采用cython编译成二进制文件进而掩盖源码的方式对代码加密. ...