2014-07-16 4:04 GMT-04:00 jarod...@libero.it <jarod...@libero.it>: > Hi there!!! > I have a file with this data > ['uc002uvo.3 ', 'uc001mae.1'] > ['uc010dya.2 ', 'uc001kko.2'] >
> I want to replace of the things after the dots, so I want to have a file > with > this output: > > ['uc002uvo ', 'uc001mae'] > ['uc010dya ', 'uc001kko'] > ... > > I try to use regular expression but I have a strange output > I'm one of those who doesn't choose regex first for string manipulation that are simpler without them. > > with open("non_annotati.csv") as p: > for i in p: > lines= i.rstrip("\n").split("\t") > mit = re.sub(r'(\.\d$)','',lines[0]) > mit2 = re.sub(r'(\.\d$)','',lines[1]) > print mit,mit2 > mit = lines[0].split('.')[0] mit = lines[1].split('.')[0] >>> s = 'uc003klv.2 ' >>> s.split('.') ['uc003klv', '2 '] > uc003klv.2 uc010lxj > uc001tzy.2 uc011kzk > uc010qdj.1 uc001iku > uc004coe.2 uc002vmf > uc002dvw.2 uc004bxn > uc001dmp.2 uc001dmo > uc002rqd.2 uc010ynl > uc010cvm.1 uc002qjc > uc003ewy.3 uc003hgx > uc002ejy.2 uc003mvb > uc002fou.1 uc010ilx > uc003vhf.2 uc010qlo > uc003mix.2 uc010tdt > uc002nez.1 uc003wxe > uc011cpu.1 uc002keg > uc001ovu.2 uc011dne > uc010zfg.1 uc001jvq > uc010jlf.2 uc011azi > uc001ors.3 uc001vzx > uc010tyt.1 uc003vih > uc010fde.2 uc002xgq > uc010bit.1 uc003zle > uc010xcb.1 uc010wsg > uc011acg.1 uc009wlp > uc002bnj.2 uc004ckd > > > Where is the error? what is wrong in my regular expression code? > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Joel Goldstick http://joelgoldstick.com
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor