t; <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 03, 2004 9:23 PM
Subject: [Tutor] Python regular expression
> Dear group,
>
> I have a file with 645,984 lines. This file is
> composedcompletely of bocks.
>
> For e.g.
>
> [Unit111]
> Na
Well, you could *try* ;-).
Okay, here's a one-pass approach:
#!/usr/bin/env python
import re
# Regular expressions stolen from PyCookbook:
#
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/132326
sec = re.compile(r'^\[(.*)\]')
eq = re.compile(r'^([^=]+)=(.*)')
def main(fname='file.ini'
On Dec 3, 2004, at 21:34, Rick Muller wrote:
The file type you mention is also called an INI file,
and is used for Windows initialization scripts, among
other things.
There's a nice recipe on this in the Python Cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65334
This will read y
The file type you mention is also called an INI file,
and is used for Windows initialization scripts, among
other things.
There's a nice recipe on this in the Python Cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65334
This will read your file in as a dictionary. You can
then d
Dear group,
I have a file with 645,984 lines. This file is
composedcompletely of bocks.
For e.g.
[Unit111]
Name=NONE
Direction=2
NumAtoms=16
NumCells=32
UnitNumber=111
UnitType=3
NumberBlocks=1
[Unit111_Block1]
Name=31318_at
BlockNumber=1
NumAtoms=16
NumCells=32
StartPosition=0
StopPosition=1