我做了一段时间的项目。这是与ACL的工作,不幸的是,野兽的性质是披露是不可能的,所以我将提供尽可能多的细节,我可以不透露任何东西。非常感谢您的帮助!你知道吗
我一直坚持要自己找到解决方案,但恐怕我对Python的了解不够,无法达到预期的效果。我已经在批处理、PowerShell甚至Bash中实现了这个结果。。。它只是没有在网络路径上以快速的速度工作,不像我们的其他Python脚本那样先在内存中缓冲,然后快速而平滑地工作。请注意,这将筛选超过500K-5M行的数据。你知道吗
示例数据.csv
GROUPS,PATH,EXPLICIT,STUFF
Group1,folder0,Explicit,somestuffhere
Group2,folder0,Explicit,somestuffhere
Group1,folder0\coolbeans,Implicit,somestuffhere
Group2,folder0\coolbeans,Implicit,Somestuffhere
Group3,folder0\coolbeans\awesomesauce,Implicit,Somestuffhere
Group3,folder1,Explicit,Somestuffhere
Group4,folder1\awesome,Implicit,Somestuffhere
Group5,folder1\awesome,Implicit,Somestuffhere
概念:
生成显式存在的每个组的列表。
生成隐式存在的每个组的列表。
两个列表都是唯一的(删除重复项)
比较两个列表,对于隐式组和显式组。
按其余组筛选整个文件内容:
将每一行以及剩余的组整行输出到单个文件中。
理论:
我知道这不仅会帮助我自己,也会帮助许多其他人寻求这个挑战。你知道吗
谢谢你的帮助!你知道吗
附加说明:Python版本2.6.6
根据管理员的要求,我以前使用过一个代码示例:如前所述。你知道吗
import csv
import sys
global exp
global imp
exp = set()
imp = set()
exc = set()
i = open(sys.argv[1], "rb")
csvr = csv.reader(i)
def expparse(target):
if "Explicit" in target:
exp.add(target[0])
def impparse(target):
if "Implicit" in target:
imp.add(target[0])
if __name__ == "__main__":
for rows in csvr:
expparse(rows)
impparse(rows)
exc = imp - exp # added with aid of Joran - Lack of knowledge to compare 2 Sets.
for rows in (exc):
print rows # Produces the right information, how do I set it as a filter?
到目前为止,我仍然不确定现在如何比较整个CSV的异常。我的目的是看看其他人会产生什么类型的代码。我想看看其他拥有更多python经验的人有什么想法,如果不带偏见的话这是有意义的话。你知道吗
反过来,如何让python获取与exc集中的行匹配的每一行?你知道吗
谢谢!你知道吗
可能就是你要找的。。。很难说
相关问题 更多 >
编程相关推荐