我正在尝试使用其他来源提供的一些学生数据来更新 csv 文件,但是他们的 csv 数据格式与我们的略有不同。
它需要根据三个标准来匹配学生的姓名、班级,最后是位置的前几个字母,因此 B 班的前几个学生Dumpt
实际上来自 Dumpton Park。
找到匹配项时
- 如果 CSV 2 中学生的记分卡为 0 或空白,则不应更新 CSV 1 中的分数列
- 如果 CSV 2 中的学生编号为 0 或空白,则不应更新 CSV 1 中的 No 列
- 否则它应该将数字从 CSV 2 导入到 CSV1
下面是一些示例数据:
CSV 1
Class,Local,Name,DPE,JJK,Score,No
Class A,York,Tom,x,x,32,
Class A,York,Jim,x,x,10,
Class A,York,Sam,x,x,32,
Class B,Dumpton Park,Sarah,x,x,,
Class B,Dumpton Park,Bob,x,x,,
Class B,Dumpton Park,Bill,x,x,,
Class A,Dover,Andy,x,x,,
Class A,Dover,Hannah,x,x,,
Class B,London,Jemma,x,x,,
Class B,London,James,x,x,,
CSV 2
"Class","Location","Student","Scorecard","Number"
"Class A","York","Jim","0","742"
"Class A","York","Sam","0","931"
"Class A","York","Tom","0","653"
"Class B","Dumpt","Bob","23.1","299"
"Class B","Dumpt","Bill","23.4","198"
"Class B","Dumpt","Sarah","23.5","12"
"Class A","Dover","Andy","23","983"
"Class A","Dover","Hannah","1","293"
"Class B","Lond","Jemma","32.2","0"
"Class B","Lond","James","32.0","0"
CSV 1 已更新(这是所需的输出)
Class,Local,Name,DPE,JJK,Score,No
Class A,York,Tom,x,x,32,653
Class A,York,Jim,x,x,10,742
Class A,York,Sam,x,x,32,653
Class B,Dumpton Park,Sarah,x,x,23.5,12
Class B,Dumpton Park,Bob,x,x,23.1,299
Class B,Dumpton Park,Bill,x,x,23.4,198
Class A,Dover,Andy,x,x,23,983
Class A,Dover,Hannah,x,x,1,293
Class B,London,Jemma,x,x,32.2,
Class B,London,James,x,x,32.0,
我真的很感激这个问题的任何帮助。谢谢奥利弗