replacing ini content

I need to save a section from an ini file , copy a new version of the ini file and then replace the values.

for example

[config]
option1=value1
option2=value2
option3=value3

[locations]
location1=uk
location2=us

save the config section, copy new ini file resulting in

[config]
option4=value4
option5=value5
option6=value6

[locations]
location1=france
location2=china

then replacing the config section with the original, ending up with

[config]
option1=value1
option2=value2
option3=value3

[locations]
location1=france
location2=china