Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95158

Re: How to use regex (re)

X-Received by 10.66.222.41 with SMTP id qj9mr9249052pac.30.1439006286572; Fri, 07 Aug 2015 20:58:06 -0700 (PDT)
X-Received by 10.50.64.180 with SMTP id p20mr17632igs.11.1439006286537; Fri, 07 Aug 2015 20:58:06 -0700 (PDT)
Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!se8no506724igc.0!news-out.google.com!o13ni9256igw.0!nntp.google.com!pg9no7908995igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Fri, 7 Aug 2015 20:58:05 -0700 (PDT)
In-Reply-To <d2k5qcFc3m4U1@mid.individual.net>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=76.167.170.40; posting-account=i8D9sgkAAAAZ8cju0XYivbbU0QS5dvO-
NNTP-Posting-Host 76.167.170.40
References <306503ec-4052-4438-b778-781797f9941a@googlegroups.com> <d2k5qcFc3m4U1@mid.individual.net>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <3b01d487-2f06-4af7-b6f2-3405f8dcd460@googlegroups.com> (permalink)
Subject Re: How to use regex (re)
From PK Khatri <piseema@gmail.com>
Injection-Date Sat, 08 Aug 2015 03:58:06 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:95158

Show key headers only | View raw


On Friday, August 7, 2015 at 9:48:35 AM UTC-7, Peter Pearson wrote:
> On Thu, 6 Aug 2015 13:06:36 -0700 (PDT), PK Khatri <piseema@gmail.com> wrote:
> > I have a following script which extracts xyz.tgz and outputs to a
> > folder which contains several sub-folders and files.
> >
> >     source_dir = "c:\\TEST"
> >     dest_dir = "c:\\TEST"
> >     for src_name in glob.glob(os.path.join(source_dir, '*.tgz')):
> >         base = os.path.basename(src_name)
> >         dest_name = os.path.join(dest_dir, base[:-4])
> >         with tarfile.open(src_name, 'r') as infile:
> >             infile.extractall(dest_dir)
> >
> > When above script is ran, the output is a single directory within that
> > directory the structure looks like this:
> >
> > folder_1
> > folder_2
> > folder_n
> > file_1
> > file_2
> > file_n
> >
> > In these folder, there are sub-folders and files. Among those file
> > there are some data i am interested in to search and output to a file.
> >
> > For eg. Among the folders there is a file called
> > **'localcli_network-ip-neighbor-list.txt**' which contains IP
> > address(s) which I would like to output to a file.
> 
> Are you asking how to determine whether the string
> "localcli_network-ip-neighbor-list.txt" appears in a filename?
> If so, the logical expression
> 
>     "localcli_network-ip-neighbor-list.txt" in filename
> 
> will do the job.
> 
> -- 
> To email me, substitute nowhere->runbox, invalid->com.

Thanks Peter.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

How to use regex (re) PK Khatri <piseema@gmail.com> - 2015-08-06 13:06 -0700
  Re: How to use regex (re) Peter Pearson <pkpearson@nowhere.invalid> - 2015-08-07 16:48 +0000
    Re: How to use regex (re) PK Khatri <piseema@gmail.com> - 2015-08-07 20:58 -0700

csiph-web