Skip to content

Instantly share code, notes, and snippets.

@nygeog
Created March 13, 2017 21:11
Show Gist options
  • Save nygeog/ae2856645f64efe487321a089f41b9df to your computer and use it in GitHub Desktop.
Save nygeog/ae2856645f64efe487321a089f41b9df to your computer and use it in GitHub Desktop.

Revisions

  1. nygeog created this gist Mar 13, 2017.
    23 changes: 23 additions & 0 deletions find-replace-carto.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    import json


    def oneTest():
    return 'so'

    def openJSON(inFile):
    with open(inFile) as json_data:
    data = json.load(json_data)
    return data

    def saveJSON(data,ouFile):
    with open(ouFile, 'w') as outfile:
    json.dump(data, outfile)

    def replaceDataset(data,oldTableName,newTableName):
    data = json.loads(json.dumps(data).replace(oldTableName,newTableName))
    return data

    def openFileReplaceDatasetSave(inFile,ouFile,oldTableName,newTableName):
    data = replaceDataset( openJSON(inFile) ,oldTableName,newTableName)
    saveJSON(data,ouFile)
    return data