找回密码
 立即注册
搜索
热搜: Excel discuz
查看: 1447|回复: 0

[项目代码] 澳洲弟弟的项目代码

[复制链接]

482

主题

7万

元宝

75万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
750849
发表于 2021-11-18 13:06:14 | 显示全部楼层 |阅读模式
  1. from docx import Document
  2. import os
  3. path = 'f:/人员信息/'
  4. list1 = []
  5. for lujing,liebiao,wenjian in os.walk(path):
  6.   for i in wenjian:
  7.     url = lujing+i
  8.     doc = Document(url)
  9.     tables = doc.tables
  10.     tb = tables[0]
  11.     tb_rows = tb.rows

  12.     row_data_name = []
  13.     rows_cells = tb_rows[0].cells
  14.     for cell in rows_cells:
  15.         row_data_name.append(cell.text)
  16.     name = row_data_name[2]
  17.     print(name)

  18.     row_date_xb = []
  19.     rows_cells = tb_rows[0].cells
  20.     for cell in rows_cells:
  21.         row_date_xb.append(cell.text)
  22.     xb = row_date_xb[6]
  23.     print(xb)

  24.     row_date_zy = []
  25.     rows_cells = tb_rows[7].cells
  26.     for cell in rows_cells:
  27.         row_date_zy.append(cell.text)
  28.     zy = row_date_zy[6]
  29.     print(zy)

  30.     row_date_zyt = []
  31.     rows_cells = tb_rows[8].cells
  32.     for cell in rows_cells:
  33.         row_date_zyt.append(cell.text)
  34.     zyt = row_date_zyt[4]
  35.     print(zyt)








  36.     row_data_tel = []
  37.     rows_cells = tb_rows[2].cells
  38.     for cell in rows_cells:
  39.         row_data_tel.append(cell.text)
  40.     tel = row_data_tel[-1]
  41.     print(tel)

  42.     row_data_name1 = []
  43.     rows_cells = tb_rows[7].cells
  44.     for cell in rows_cells:
  45.         row_data_name1.append(cell.text)
  46.     name1 = row_data_name1[2]
  47.     print(name1)

  48.     row_data_name2 = []
  49.     rows_cells = tb_rows[10].cells
  50.     for cell in rows_cells:
  51.         row_data_name2.append(cell.text)
  52.     name2 = row_data_name2[2]
  53.     print(name2)


  54.     list1.append([name,xb,tel,name2,name1,zy,zyt])
  55. print(list1)
  56. output = open('f:/人员信息/001.xls','w',encoding='gbk')
  57. output.write('受援人\t性别\t联系电话\t案件名称\t承办人姓名\t承办人执业单位\t承办人联系电话\n')
  58. for i in range(len(list1)):
  59.         for j in range(len(list1[i])):
  60.                 output.write(str(list1[i][j]))
  61.                 output.write('\t')
  62.         output.write('\n')
  63. output.close()
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|五花八门论坛 ( 豫ICP备15031300号-3 )

GMT+8, 2024-4-26 07:23 , Processed in 0.093499 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表