Author
|
Thread
|
|
|
|
|
LightningCrash
Smile like Bob, order your free LC today
Joined: 03 Apr 2003
Posts: 5020
|
here
parsecnc.py
Code
import os, sys
cncfile=open(sys.argv[1],'r')
f=cncfile.read()
f=f.splitlines()
def dumpprog(line,filename):
wri = open(filename,'a')
line=line + '\n'
wri.write(line)
w='defaultoutput.nc'
while len(f)>0:
line = f.pop(0)
if line.find('o')==0:
dumpprog('%',w)
w=line + '.nc'
dumpprog('%',w)
line=[]
if len(line)>0: dumpprog(line,w)
dumpprog('%',w)
Usage: python parsecnc.py filename
Example
$mkdir ~/tmp2929
$cd ~/tmp2929
$python ~/workspace/souperparser/src/parsecnc.py ~/cnctest
$ls
o05050.nc o05150.nc o05250.nc defaultoutput.nc
$cat o05050.nc
%
g123 m23 g234
g222 m222 g44
%
|
Fri Oct 31, 2008 8:27 am
|
|
|
|
|
|
|
|
|
|