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()
pj_0001_compare_col_csv的更多相关文章
随机推荐
- 合肥光源纵向震荡数据源相关PV的增补
合肥光源纵向震荡数据源相关PV 昨天发了上面那篇,对于那张二维纵向时间的图又做了些分析,因为要显示分析的结果,又增加了几个PV,说明如下: HLSII:BD:BCMSDS:Time:Spectrum ...
- ORACLE数据库起不来
由于意外导致数据库无法启动 首先切换到oracle用户,查看profile文件. su - oracle cat .bash_profile 然后进入数据库,查看挂载上 sqlplus "/ ...
- .net core Ubuntu下docker部署(精简版)
一.首先先添加一个.netCore 项目,选择启用docker(我用的是vs2019,之前的可能需要手动点击项目添加docker支持) 没有的话需要手动添加 之后你的项目会存在这个dockerfile ...
- U-Boot-基础概念与学习分享
U-Boot 基础概念与学习分享 Board: rockchip-px30, armv8, Cortex-A35 U-Boot: rockchip-linux/u-boot, branch next- ...
- select去除默认样式
select { /*Chrome同Firefox与IE里面的右侧三角显示的样式不同*/ border: solid 1px #ddd; /*将默认的select选择框样式清除*/ appearanc ...
- PACS系统各个功能介绍--九五小庞
PACS系统是HIS系统的重要组成部分,医生可在电脑上查看患者的医学影像报告. ■ 支持心电DICOM,心电图浏览和处理(显示格式.纸速.增益.滤波.测量等). ■ 支持MPR.CPR.MIP.SSD ...
- left join(二)
left join 通俗的解释:以左表为主表,返回左表的所有行,如果右表中没有匹配,则依然会有左表的记录,右表字段用null填充.看起来非常好理解,但实际操作的过程中可能会有一些很容易被忽略的点. 一 ...
- vscode cmake工程launch和task文件设置
1.launch.json文件基本设置 { // Use IntelliSense to learn about possible attributes. // Hover to view descr ...
- 常用的基本Dos命令
Windows+R: 输入cmd,运行控制台 #盘符切换: 盘名+: #查看当前目录下的所有文件: dir #切换目录: cd+文件名 #返回上一级: cd.. #清理屏幕: cls #退出终端: e ...
- org.elasticsearch.ElasticsearchException: not all primary shards of [.geoip_databases] index are active解决办法
解决办法 在配置elasticsearch.yml中加上 ingest.geoip.downloader.enabled: false