Python CSV在读入字典后搜索特定值
我需要一些帮助,使用 Python 将特定值读取到字典中。我有一个包含用户编号的 csv 文件。所以用户 1,2,3...每个用户都在特定的部门 1,2,3...并且每个部门都在特定的建筑物 1,2,3...所以我需要知道如何列出1 号楼的部门 1 的所有用户,然后是 1 号楼的部门 2 的所有用户,依此类推。我一直在尝试并使用 csv.ReadDict 将所有内容读入大型字典中,但是如果我可以搜索我读入每个字典字典中的条目,那么这将起作用。关于如何排序这个文件有什么想法吗? CSV 包含超过 150,000 个用户条目。每行是一个新用户,列出 3 个属性,user_name、departmentnumber、department Building。有100个部门、100栋大楼和15万用户。有什么想法可以用一个简短的脚本来解决所有这些问题吗?感谢您提前的帮助
I need a little help reading specific values into a dictionary using Python. I have a csv file with User numbers. So user 1,2,3... each user is within a specific department 1,2,3... and each department is in a specific building 1,2,3... So I need to know how can I list all the users in department one in building 1 then department 2 in building 1 so on. I have been trying and have read everything into a massive dictionary using csv.ReadDict, but this would work if I could search through which entries I read into each dictionary of dictionaries. Any ideas for how to sort through this file? The CSV has over 150,000 entries for users. Each row is a new user and it lists 3 attributes, user_name, departmentnumber, department building. There are a 100 departments and 100 buildings and 150,000 users. Any ideas on a short script to sort them all out? Thanks for your help in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
蛮力方法看起来
可以扩展到
A brute-force approach would look like
It could then be extended to