Sunday, March 16, 2008

Create a script that will modify a text file

I am trying to create a script that will modify a text file.

I would like help writing a script that will open a text file called 'Event22.txt', and change the value 'Event 22' to 'Event 23', and 'id-22' to 'id=23' then save the file as 'Event 23'. The test looks like this:

"wms_title" "Event 22"
END
# Get the lines from the 'location' column of the 'settlement' table
DATA "location from
(SELECT
sp.settlement_part_id,
sp.name as settlementname,
sp.location,
lr.loss_unit as unit,
lr.value as val
FROM (settlement_part sp left join loss_result lr on (sp.settlement_part_id=lr.item_id and lr.item_type='settlement_part') )
left join loss_model lm on lm.model_id=lr.model_id
WHERE lr.model_id in (SELECT l.model_id FROM loss_model l WHERE l.calculation_session_id=22)
and lr.loss_unit='patients (mean)'

) as set_calc
using unique settlement_part_id using SRID=4326

"