【发布时间】:2018-01-02 06:26:50
【问题描述】:
构建一个 python 程序,从 excel 数据转储中解析手机号码并将其存储在不同的 excel 文件中。数据转储文件附后。
- 手机号码必须是 10 位数。
- 手机号码可以以 0 或 +91 开头。
- 手机号码必须以 9 或 8 或 7 开头。
- 每个单元格可能有多个数字。存储每个单元格中的数字,用逗号分隔。
我写了这段代码:
import xlrd
import string
import re
workbook = xlrd.open_workbook('Data_Dump.xlsx')
RE_phone = re.compile("^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$")
for num in range():
row = sheet1.row(num)
for index, col in enumerate(cols):
value = txt[index] + num
row.write(index, value)
它不工作。我是python新手。如果我能被引导到正确的方向,将不胜感激。
数据转储
WORKLOAD REPOSITORY report for 9531066111 "" 93979695025 "DB Name DB Id Instance Inst Num Startup Time Release RAC" 7812107175 "------------ ----------- ------------ -------- --------------- ----------- ---" 84256569115
9227901842 "DB Name DB Id Instance Inst Num Startup Time Release RAC" 99868256926 "------------ ----------- ------------ -------- --------------- ----------- ---" 7400963376 "FXBPCU25 832272769 FXBPCU25 1 07-Sep-17 05:09 11.2.0.4.0 NO " +918347699241
DB Name DB Id Instance Inst Num Startup Time Release RAC 9924737563 "------------ ----------- ------------ -------- --------------- ----------- ---" 90424664527 "FXBPCU25 832272769 FXBPCU25 1 07-Sep-17 05:09 11.2.0.4.0 NO " 7989819567 "" +918044534972
------------ ----------- ------------ -------- --------------- ----------- --- 9621573294 "FXBPCU25 832272769 FXBPCU25 1 07-Sep-17 05:09 11.2.0.4.0 NO " 97393021728 "" 7686655298 "Host Name Platform CPUs Co
FXBPCU25 832272769 FXBPCU25 1 07-Sep-17 05:09 11.2.0.4.0 NO 9154788735 "" 92725176229 "Host Name Platform CPUs Cores Sockets Memory(GB)" 7383491029 "---------------- -------------------------------- ---- ----- ------- ----------" +918797011444
9851624456 "Host Name Platform CPUs Cores Sockets Memory(GB)" 99693533430 "---------------- -------------------------------- ---- ----- ------- ----------" 70803267410 "CNDBFXCEDBZP32 Linux x86 64-bit 48 24 2 504.04" +918493847175
Host Name Platform CPUs Cores Sockets Memory(GB) 9548460187 "---------------- -------------------------------- ---- ----- ------- ----------" 2136681081 "CNDBFXCEDBZP32 Linux x86 64-bit 48 24 2 504.04" 77771624611 "" +918190682906
---------------- -------------------------------- ---- ----- ------- ---------- 9659741698 "CNDBFXCEDBZP32 Linux x86 64-bit 48 24 2 504.04" 2833516802 "" 74739981912 " Snap Id Snap Time Sessions Curs
CNDBFXCEDBZP32 Linux x86 64-bit 48 24 2 504.04 9356577429 "" 2530352533 " Snap Id Snap Time Sessions Curs/Sess" 71708339213 " --------- ------------------- -------- ---------" +918476374828
90534131410 " Snap Id Snap Time Sessions Curs/Sess" 2227188264 " --------- ------------------- -------- ---------" 78676696414 "Begin Snap: 20863 21-Nov-17 07:30:17 390 9.1" +918173210559
Snap Id Snap Time Sessions Curs/Sess 95866285811 " --------- ------------------- -------- ---------" 2282829015 "Begin Snap: 20863 21-Nov-17 07:30:17 390 9.1" 75645053715 " End Snap: 20865 21-Nov-17 08:30:27 407 9.3" +9188700462710
--------- ------------------- -------- --------- 92834643112 "Begin Snap: 20863 21-Nov-17 07:30:17 390 9.1" 2979664736 " End Snap: 20865 21-Nov-17 08:30:27 407 9.3" 8311151721 " Elapsed: 60.18 (mins)" 09873786851
Begin Snap: 20863 21-Nov-17 07:30:17 390 9.1 99803000313 " End Snap: 20865 21-Nov-17 08:30:27 407 9.3" 2676500467 " Elapsed: 60.18 (mins)" 8007987452 " DB Time: 1,027.15 (mins)" 09131216302
End Snap: 20865 21-Nov-17 08:30:27 407 9.3 96771357614 " Elapsed: 60.18 (mins)" 2373336198 " DB Time: 1,027.15 (mins)" 8704823173 "" 07897784883
Elapsed: 60.18 (mins) 93739714915 " DB Time: 1,027.15 (mins)" 2070171929 "" 8401658894 "Load Profile Per Second Per Transaction Per Exec Per Call" 09988292054
DB Time: 1,027.15 (mins) 90708072216 "" 27670076410 "Load Profile Per Second Per Transaction Per Exec Per Call" 8098494625 "~~~~~~~~~~~~~~~ --------------- --------------- --------- ---------" 09569660095
97676429417 "Load Profile Per Second Per Transaction Per Exec Per Call" 24638433711 "~~~~~~~~~~~~~~~ --------------- --------------- --------- ---------" 8795330346 " DB Time(s): 17.1 0.2 0.00 0.00" 08660167276
Load Profile Per Second Per Transaction Per Exec Per Call 95201194218 "~~~~~~~~~~~~~~~ --------------- --------------- --------- ---------" 29970588012 " DB Time(s): 17.1 0.2 0.00 0.00" 8492166077 " DB CPU(s): 2.2 0.0 0.00 0.00" 07750674467
~~~~~~~~~~~~~~~ --------------- --------------- --------- --------- 92169551519 " DB Time(s): 17.1 0.2 0.00 0.00" 25859150013 " DB CPU(s): 2.2 0.0 0.00 0.00" 8189001808 " Redo size (bytes): 13,798,845.9 151,217.7" 09841181638
DB Time(s): 17.1 0.2 0.00 0.00 99137908720 " DB CPU(s): 2.2 0.0 0.00 0.00" 22827507314 " Redo size (bytes): 13,798,845.9 151,217.7" 8885837529 " Logical read (blocks): 237,897.7 2,607.1" 08931688819
DB CPU(s): 2.2 0.0 0.00 0.00 96106266021 " Redo size (bytes): 13,798,845.9 151,217.7" 29795864515 " Logical read (blocks): 237,897.7 2,607.1" 85826732510 " Block changes: 77,067.0 844.6" 06289783331
Redo size (bytes): 13,798,845.9 151,217.7 93074623222 " Logical read (blocks): 237,897.7 2,607.1" 7024764281 " Block changes: 77,067.0 844.6" 82795089811 " Physical read (blocks): 4,615.7 50.6" 04062071652
Logical read (blocks): 237,897.7 2,607.1 90042980523 " Block changes: 77,067.0 844.6" 7721599992 " Physical read (blocks): 4,615.7 50.6" 89763447012 "Physical write (blocks): 4,771.9 52.3" 01333593193
Block changes: 77,067.0 844.6 97011337724 " Physical read (blocks): 4,615.7 50.6" 7418435723 "Physical write (blocks): 4,771.9 52.3" 80319854613 " Read IO requests: 4,055.5 44.4" 07605114724
Physical read (blocks): 4,615.7 50.6 01990906619 "Physical write (blocks): 4,771.9 52.3" 7115271454 " Read IO requests: 4,055.5 44.4" 87288211814 " Write IO requests: 2,717.1 29.8" 03904820465
Physical write (blocks): 4,771.9 52.3 07447863537 " Read IO requests: 4,055.5 44.4" +0010422710 " Write IO requests: 2,717.1 29.8" 04719385078 " Read IO (MB): 36.1 0.4" 01176342006
【问题讨论】:
-
请发布示例输入和输出。另外,您能否更清楚地知道什么不起作用?
-
这是一个data_dump,我必须在其中解析手机号码。数字格式应为以下格式 =91xxxxxxxx 或 0xxxxxxxx 或 7xxxxxxxx 或 8xxxxxxxx 或 9xxxxxxxx
-
是的。你能告诉我们
data_dump的样子吗? -
我已经编辑并上传了数据转储
标签: python excel loops for-loop xlsx