#!/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. C++练习4 引用的定义与使用

    使用 & 为变量和常量作为引用 1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int oneInt ...

  2. DVWA靶场实战(十四)——JavaScript

    DVWA靶场实战(十四) 五.Java Script: 1.漏洞原理: 这里的JavaScript其实是JavaScript Attack也就是JS攻击.JavaScript是一种基于对象和事件驱动的 ...

  3. 交叉熵损失CrossEntropyLoss

    在各种深度学习框架中,我们最常用的损失函数就是交叉熵,熵是用来描述一个系统的混乱程度,通过交叉熵我们就能够确定预测数据与真实数据的相近程度.交叉熵越小,表示数据越接近真实样本. 1 分类任务的损失计算 ...

  4. Slave_IO_Running: Connecting--一种问题的解决方案

    主要有三个原因: 1.网络不同 2.密码不对 3.pos不对 这里只介绍我碰到的问题--不能远程连接数据库.即在从机上对主机进行以下命令 mysql -u**** -p**** -h192.168.* ...

  5. JZOJ 2022.02.11【提高A组】模拟

    \(\text{Solution}\) 首先把 \(T2\) 给切了,\(T1\) 找半天规律找不到 然后打了个表算是暴力了 \(T3\) 也暴... 太暴了... \(T4\) 直接啥也不会 \(\ ...

  6. Word 表格对文字、图文进行排版

    在以前,Web 前端工程师利用 <table /> 元素对网页布局进行排版,但是如今却不推荐此元素排版了,而是改用 <div /> 元素和 CSS 弹性布局(或网格布局)对网页 ...

  7. RocketMQ - 消费者Rebalance机制

    客户端是通过Rebalance服务做到高可靠的.当发生Broker掉线.消费者实例掉线.Topic 扩容等各种突发情况时,消费者组中的消费者实例是怎么重平衡,以支持全部队列的正常消费的呢? Rebal ...

  8. c# 使用 Redis

    1.安装Redis 我是在Windows上安装redis的,Redis官网我只看到linux版本的,得使用别人提供的windows版本 菜鸟教程提供的redis下载地址:https://github. ...

  9. Windows清除DNS缓存

    第一步,刷新DNS WIN+R 输入cmd 再输入ipconfig/flushdns 第二步,恢复默认 输入netsh winsock reset 重启电脑.

  10. JavaSE总结(2)

    控制语句idea.方法重载控制语句1.顺序结构从上到下从左到右依次执行2.判断结构    a.if(判断表达式){        语句体;    }    b.if(判断表达式){        语句 ...