My complete code: from sys import argv from string import find, split, strip import os import zipfile def import_files(): items = [] '''stub for import''' form = form_factory(Field('seqzip', 'upload', label="Sequence Files (.zip)", requires=IS_NOT_EMPTY(), uploadfield=False)) if form.accepts(request.vars): zf = zipfile.ZipFile(request.vars.seqzip.file) for name in zf.namelist(): filename = name.split('/')[-1] file_raw = zf.read(name) jsoligo = ''.join(split(''.join(file_raw)))[::-1] rev =(jsoligo[find(jsoligo,'/')+2:find(jsoligo,';')][::-1])
db.plugin_seq.insert(filename=filename,raw_seq=file_raw,processed_seq=rev) if db(db.plugin_seq.filename==filename).count(): rec = db(db.plugin_seq.filename==filename).select().first() rec.update_record(raw_seq=file_raw,processed_seq=rev) db.commit() return ('<br>'.join(zf.namelist())) return form def records(): values = [r.processed_seq for r in db().select(db.plugin_seq.processed_seq)] return values def index(): return dict() My complete file path: home/praveen/web2py/web2py/PCGENE_Format/N77CDR1K.ATD is displayed in out put. ****************It is sample of my output**************************************+ GCGCAACGCAATTAATGTGAGTTACCTCACTCATTAGGCACCCCAGGCTTTACACTTTATGCTTCCGGCCACAGGAAACAGCTATGACCATGATTACGCCAAGCTTGCATGCCTGCAGGTC|CGENE_Forma|CGENE_Forma|CGENE_Forma|CGENE_Forma|CGENE_Forma||CGENE_Forma|CGENE_Forma|CGENE_Forma|CGENE_Formrma|rimer_forma|rimer_forma||rimer_forma|rimer_forma|rimer_forma|rimer_forma|rimer_forma|rimer_forma||GCGCAACGCAATTAATGTGAGTTACCTCACTCATTAGGCACCCCAGGCTTTACACTTTATGCTTCCGGCTCTTTAGCTGTGGAAGATTTCTTGTCATCGAATATACATCATATGTAACAATTCTTTTTCTCAATGTTTATGCGTGACCCAAACATA eb2py/PCGENE_Format/NGFP_TRK.1/home/praveen/web2py/web2py/PCGENE_Format/NP7C1TRK.1D/home/praveen/web2py/web2py/PCGENE_Format/NPKGTS1/home/praveen/web2py/web2p']||['home/praveen/web2py/web2py/sampleforma']||['home/praveen/web2py/web2py/sampleforma', The contents of the file producing the values is the sequence like GCTTCCGGCTCTTTAGCTGTGGAAGATTTCTTGTCATCGAATATACATCATATGTAACAATTCTTTTTCTCAATGTTTATGCGTGACCCAAACATA, but along this seq is followed by |CGENE_Forma|CGENE_Forma|CGENE_Forma|CGENE_Forma|CGENE_Forma||CGENE_Forma|CGENEimer_forma|rimer_forma|rimer_forma||GCGCAACGCAATTAATGTGAGTTACCTCACTCATTAGGCACCCCA eb2py/PCGENE_Format/NGFP_TRK.1/home/praveen/web2py/web2py/PCGENE_Format/NP7C1TRK.1D/home/praveen/web2py/web2py/PCGENE_Format/NPKGTS1/home/praveen/web2py/web2p' which I don't want to. On Sun, Jun 17, 2012 at 4:30 PM, Anthony <abasta...@gmail.com> wrote: > What's your current complete code for generating the values and inserting > them in the db? What's an example of a complete file path and name within > the zip file as well as the contents of that file that is producing a value > like the ones below? > > ya its in subfolder but with ' filename = name.split('/')[-1]' I am able >> to read the file names and with 'file_raw = zf.read(name) ' i am able to >> read the sequence in the file .But the other problem with table is not >> solved I am still getting unwanted information like file path for example >> like "web2py/PCGENE_Format/NGFP_**TRK.1/home/praveen/web2py/** >> web2py/PCGENE_Format/NP7C1TRK.**1D/home/praveen/web2py/web2py/** >> PCGENE_Format/NPKGTS1/home/**praveen/web2py/web2p']||['** >> home/praveen/web2py/web2py/**sampleforma']||['home/praveen/** >> web2py/web2py/sampleforma'....**...." >> with the sequence information .I think that the problem in the way I am >> inserting the records .I have used >> db.plugin_seq.insert(filename=**filename,raw_seq=file_raw,** >> processed_seq=rev) >> if db(db.plugin_seq.filename==**filename).count(): >> >> rec = >> db(db.plugin_seq.filename==**filename).select().first() >> >> rec.update_record(raw_seq=** >> file_raw,processed_seq=rev) >> db.commit() >> to insert and update record and to extract the processed sequence I am >> using >> def records(): >> values = [r.processed_seq for r in db().select(db.plugin_seq.** >> processed_seq)] >> return values >> >> >> >> I have tried that by removing the subfolder but its giving an error >>>> import zipfile >>>> def zipfolder(): >>>> zf = zipfile.ZipFile('/home/**praveen**/job_files/seq_data/** >>>> PCGENE_**Format.zip') >>>> fil = zf.open('/home/praveen/job_**fil**es/seq_data/PCGENE_Format. >>>> **zip/**NPKGTS1') >>>> print fil >>>> error: >>>> There is no item named '/home/praveen/job_files/seq_**d** >>>> ata/PCGENE_Format.zip/**NPKGTS1' in the archive" >>>> >>> >>> No, I was asking whether there were any subfolders inside the zip file >>> itself (you can zip an entire directory structure). If so, for files that >>> are inside subfolders *within* the zip file, I would think you would >>> have to refer to the entire path, not just the filename. >>> >>> Anthony >>> >> >>