#!/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++练习6 不同参数的传递方式

    当函数的形参是变量时,函数内的操作是只对形参的操作,并不会对实参造成影响 当函数的形参是引用时,在函数内对形参操作的同时也会对实参造成影响 1 #include <iostream> 2 ...

  2. Nacos服务调用(基于Openfeign)

    在<<Nacos服务注册>>这篇文章里,我搭建了一个nacos服务中心,并且注册了一个服务,下面我们来看在上一篇文章的基础上,怎样用Openfeign来调用这个服务. 0.同上 ...

  3. select去除默认样式

    select { /*Chrome同Firefox与IE里面的右侧三角显示的样式不同*/ border: solid 1px #ddd; /*将默认的select选择框样式清除*/ appearanc ...

  4. LeetCode-396 选转函数

    来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/rotate-function 题目描述 给定一个长度为 n 的整数数组 nums . 假设 ar ...

  5. c# 在自定义类中控制form窗体中的控件 赋值或修改属性

    c# 在自定义类中控制form窗体中的控件 赋值或修改属性 首先在 自定义类 的外面  声明一个 委托模块 //声明一个委托模块 用来改变form1 窗体中的控件值 public delegate v ...

  6. 判断js对象每个字段是否为空

    for(var key in obj) { if (!obj[key])return; }

  7. 【C学习笔记】day3-3 编写程序数一下 1到 100 的所有整数中出现多少个数字9

    #include <stdio.h> int main() { int cou=0; for (int i = 1; i <= 100; i++) { if (i % 10 == 9 ...

  8. nginx 更改配置client_max_body_size nginx.conf 修改默认限制上传附件大小

    Nginx 上传大文件超时解决办法 情况如下:用nginx作代理服务器,上传大文件时(测试上传50m的文件),提示上传超时或文件过大. 原因是nginx对上传文件大小有限制,而且默认是1M.另外,若上 ...

  9. Python 20个常用库

    Requests.Kenneth Reitz写的最富盛名的http库.每个Python程序员都应该有它. Scrapy.如果你从事爬虫相关的工作,那么这个库也是必不可少的.用过它之后你就不会再想用别的 ...

  10. transformers 之Trainer对应的数据加载

    基础信息说明 本文以Seq2SeqTrainer作为实例,来讨论其模型训练时的数据加载方式 预训练模型:opus-mt-en-zh 数据集:本地数据集 任务:en-zh 机器翻译 数据加载 Train ...