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


Groups > comp.lang.python > #95091

How to use regex (re)

Newsgroups comp.lang.python
Date 2015-08-06 13:06 -0700
Message-ID <306503ec-4052-4438-b778-781797f9941a@googlegroups.com> (permalink)
Subject How to use regex (re)
From PK Khatri <piseema@gmail.com>

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextNext 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