#!/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. ‘mongo‘不是内部或外部命令,也不是可运行的程序或批处理文件

    出现问题原因: MongoDB环境变量未配置 解决办法: 1)右击我的电脑-->属性,进入系统属性界面,点击如下图所示位置的[高级系统设置],在弹窗的[系统属性]的[高级]选项卡右下角点击[环境 ...

  2. JZOJ 3184. 【GDOI2013模拟7】最大异或和

    最大异或和 可持久化字典树经典题 题目网上自己找 来波模板 \(Code\) #include<cstdio> #include<iostream> using namespa ...

  3. Diffusers中基于Stable Diffusion的哪些图像操作

    目录 辅助函数 Text-To-Image Image-To-Image In-painting Upscale Instruct-Pix2Pix 基于Stable Diffusion的哪些图像操作们 ...

  4. ElasticSearch7.6入门

    笔记记录 B站狂神说Java的ElasticSearch课程:https://www.bilibili.com/video/BV17a4y1x7zq 一.ElasticSearch概述 官网:http ...

  5. 三天吃透Java虚拟机面试八股文

    本文已经收录到Github仓库,该仓库包含计算机基础.Java基础.多线程.JVM.数据库.Redis.Spring.Mybatis.SpringMVC.SpringBoot.分布式.微服务.设计模式 ...

  6. fixed 定位元素超出内容 overflow 不滚动

    假如,一个父元素的定位是 fixed,其所有子元素的高度加起来超过了父元素,父元素设置 overflow: auto.有可能出现不滚动的问题,发生的情况有横向和竖向的. 竖向滚动:必须要设置父元素的高 ...

  7. html(Angular) 调用本地安装exe程序

    1.写注册表 新建 .reg文件 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\creoparametric] "URL P ...

  8. vue中使用xlsx 导出表格

         <t-table v-show="false" id="exportTab" row-key="index" :data=& ...

  9. pycharm 关闭符号自动补全

    insert pair bracket 是三种括号的自动补全 insert pair quote 是两种引号的自动补全

  10. SOJ1737 题解

    题意 给定一个长度为 \(n\) 的串 \(S\). 定义 \(occ(T)\) 表示串 \(T\) 在 \(S\) 中出现的次数. \(q\) 次询问,每次询问给定一个区间 \([l,r]\),查询 ...