# no viable alternative at input '"....

**URL:** <https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397>\
**Category:** Ignition\
**Created:** [January 26, 2022, 12:37pm UTC](https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397 "2022-01-26T12:37:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rea\_Berberi](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@Rea\_Berberi](https://forum.inductiveautomation.com/u/Rea_Berberi)\
**Post date:** [January 26, 2022, 12:37pm UTC](https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397/1 "2022-01-26T12:37:44Z")

</div>

SyntaxError: no viable alternative at input ‘"{genPath}/{dataTag[0][‘name’]}"’ (, line 98)

**Code:**

```auto
`import json

filePath = 'E:\\tags.json'        
tagPaths = ["[default]"]
recursive = True
 
system.tag.exportTags(filePath, tagPaths, recursive)    

#Load JSON file
with open("tags.json") as f:
    data = json.load(f)
        
#Load XML template of GroupConfig from a text file
with open("template.txt", 'r') as f:
    TXML = f.read()
    
genPath = "" 

#Code to generate the path of the GroupConfig
dataX = data
while True:
    if dataX["tagType"] == "Folder":
        genPath += dataX["name"] + "/"
    
    try:
        dataX = dataX["tags"][0]
    except:
        break
genPath = genPath[:-1]
    
#Code to get the list of tags
dataTags = []
dataX = data
for lvl in genPath.split("/"):
    if dataX["name"] == lvl:
        if len(genPath.split("/")) == genPath.split("/").index(lvl) + 1:
            dataTags = dataX["tags"]
            break
        else:
            dataX = dataX["tags"][0]
    
tempDataTags = []        
for dataTag in dataTags:
    tempDataTags.append([dataTag, genPath])
dataTags = tempDataTags
            
#Checking for nested tags
while True:
    for dataTag in dataTags:
        if dataTag[0]["tagType"] == "Folder":
            for nDataTag in dataTag[0]["tags"]:
                dataTags.append([nDataTag, dataTag[1] + "/" + dataTag[0]["name"]])
            dataTags.remove(dataTag)
            newAdded = True
        else:
            newAdded = False
            
    if newAdded == False:
        break
    else:
        continue
            

#base XML structure with a vaiable '[[[TEMP]]]' to replace with the data
finalXML = "<Project><Groups>[[[TEMP]]]</Groups></Project>"

#EngHigh snippet, well be used to insert later in the code
engHigh = """<ItemConfig name="EngHigh" typeId="3">
          <Property name="TARGET_DATA_TYPE">5</Property>
          <Property name="DRIVING_TAG_PATH">[default]Enterprise 1/Site 1/Area 1/Line 1/Machine 1/Tag 1.EngHigh</Property>
          <Property name="TARGET_NAME">EngHigh</Property>
          <Property name="TARGET_TYPE">1</Property>
       </ItemConfig>"""

tempXML = "" #Temp vaiable to append groupConfig of each tags

#Looping Tags, generating GroupConfig for each tags, and appending to tempXML
for dataTag in dataTags:
    TEMP = TXML
    genPath = dataTag[1]
    
   
    try:
            #Taking historyProvider value to insert into DATA_SOURCE
        HP = dataTag[0]["historyProvider"]
        TEMP = TEMP.replace("[[[--SOURCE--]]]", HP)
   
        
        #if EngHigh is in the tags, it will be added to the XML
        try:
            EH = dataTag[0]["engHigh"]
            TEMP = TEMP.replace("[[[--ENGHIGH--]]]", engHigh)
        except:
            TEMP = TEMP.replace("[[[--ENGHIGH--]]]", "")
            
        #Inserting PATH to the XML
        TEMP = TEMP.replace("[[[--PATH--]]]", f"{genPath}/{dataTag[0]['name']}")
        TEMP = TEMP.replace("[[[--GCPATH--]]]", f"ContextualizedData/{genPath}")
        
        #Inserting NAME to the XML 'GroupConfig'
        TEMP = TEMP.replace("[[[--GCNAME--]]]", dataTag[0]["name"])
        
        #Appending to tempXML, generated GroupConfig of a tag
        tempXML += TEMP
        
    except KeyError:
        pass

#Adding all Generated GroupConfig to the finalXML
finalXML = finalXML.replace("[[[TEMP]]]", tempXML)

#Saving the XML String as XML file
with open("project.xml", "w") as f:
    f.write(finalXML)

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 26, 2022, 12:51pm UTC](https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397/2 "2022-01-26T12:51:46Z")

</div>

Welcome!

Let’s start by editing your post to format the code portion. This will make it both easier to read and perhaps spot your issue more readily. 🙂

- At the bottom of your post there is a little pencil button to edit your post.
- Highlight the code portion of your post
- Click on the `</>` button in the editor.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 26, 2022, 1:01pm UTC](https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397/3 "2022-01-26T13:01:19Z")

</div>

At first looks though, keep in mind that the Jython version is 2.7, which does not support f-strings.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [January 26, 2022, 2:19pm UTC](https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397/4 "2022-01-26T14:19:47Z")

</div>

> [@Rea\_Berberi](#):
>
> with open(“tags.json”) as f:

Make sure those quotes are `"`, not `“`.  
Also, as Jordan said, there are no fstrings in jython, you'll need to use older formatting methods

```python
"hello {user}".format(user="Rea_Berberi")
"hello {0}".format("Rea_Berberi")
"hello %s" % ("Rea_Berberi")

```

and the likes.

---

<div class="post-metadata">

**Author:** ![Rea\_Berberi](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@Rea\_Berberi](https://forum.inductiveautomation.com/u/Rea_Berberi)\
**Post date:** [January 27, 2022, 11:54pm UTC](https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397/5 "2022-01-27T23:54:23Z")

</div>

They were so helpful. I have resolved it. Thank you!

---

<div class="post-metadata">

**Author:** ![Rea\_Berberi](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@Rea\_Berberi](https://forum.inductiveautomation.com/u/Rea_Berberi)\
**Post date:** [January 28, 2022, 12:03am UTC](https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397/6 "2022-01-28T00:03:32Z")

</div>

Thank you for your answer it was so helpful. Just one more question : Is there a way to import an XML file from local env with transaction group configuration using script?

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [January 28, 2022, 6:22am UTC](https://forum.inductiveautomation.com/t/no-viable-alternative-at-input/55397/7 "2022-01-28T06:22:10Z")

</div>

> [@Import transaction group from XML](https://forum.inductiveautomation.com/t/import-transaction-group-from-xml/55464):
>
> Is there a way to import an XML file from local env with transaction group configuration through scripting?
