1

我有 2 个包含数千个数据的 excel 文件。我想从 file1 中获取行并搜索整个 file2 并将重复的输出到 file3。

   file 1                        file2                      file3
 abc.bcg@gmail.com            abc.bcg_12253              abc.bcg_12253
 bcg.abc@gmail.com            efx.rfz_12345              def.xyz_08345
  def.xyz@gmail.com           wqr.qtf_34567
                              zxc.mnb_98764
                              def.xyz_08345

       FileReader = csv.DictReader(f)
            for row in FileReader:
                    emailLegalFile = row['email']
                    name_emailFile = emailFile[:emailLegalFile.find('@')]
                    print name_emailLegalFile

                    #with open(inputfile, 'rb') as d:
                    inputFileReader = csv.DictReader(d)
                    for r in inputFileReader:
                            if name_emailFile in  r['google_email']:
                                    date = r['date']
                                    time = r['time']
                                    t_format = r['format']
                                    file_size = r['file_size']
                                    google_email = r['google_email']

                                    #writer = csv.writer(w)

                                    #dic = {'date': date, 'time':time,'format':t_format,'file_size':file_size, 'google_email':google_email}

                                    #writer.writerow(dic)
                                    list = [date,time,t_format,file_size,google_email]

                                    with open('result.csv','a') as e:
                                            writer_1 = csv.writer(e,delimiter=',',quotechar='|', quoting=csv.QUOTE_MINIMAL)
                                            writer_1.writerow(list)

File2 有 5 列,但只想与第 5 列匹配。

我得到的输出只是第一个值,即 abc.bcg_12253。

请帮我解决这个问题。

谢谢

4

0 回答 0