Wie erstelle ich eine strukturierte AQL -Abfrage aus einer Bildliste mit Python?Python

Python-Programme
Anonymous
 Wie erstelle ich eine strukturierte AQL -Abfrage aus einer Bildliste mit Python?

Post by Anonymous »

Ich bin neu in Python und kann Hilfe verwenden. Schleifen Sie durch "Images.txt" durch, um die Bildnamen aus jeder Zeile zu erhalten und die Abfrage zu füllen. Die Anzahl der Bilder wird sich wahrscheinlich ändern. < /P>

Code: Select all

**items.find({
"$and": [
{
"repo": {
"$eq": "docker-repository-name"
}
},

{
"$or": [**

{
"path": {
"$match": "Image from file"
}
},

{
"path": {
"$match": "Image from file"
}
},

{
"path": {
"$match": "Image from file"
}
}

}
}
]
}
]
})
< /code>
Ich habe versucht, einen Codeblock zu verwenden, um den tatsächlichen Code zu schreiben: < /p>
code_block = """

{
"path": {"$match":

"""
< /code>
Dann versuchte es, die Datei durchzuführen, aber dies ist nur das Lesen der Bildnamen und das Hinzufügen eines Kommas bis zum Ende jeder Zeile. < /p>
def generate_aql_from_text(text_file_path, aql_file_path):
"""Generates an AQL file from an external text file."""

with open(text_file_path, 'r') as text_file, \
open(aql_file_path, 'w') as aql_file:

for line in text_file:
query = line.strip()
if query:  # Skip empty lines
aql_file.write(query + ';\n')

if __name__ == "__main__":
text_file_path = "images.txt"  # Replace with your text file path
aql_file_path = "output.aql"  # Replace with your desired AQL file path

generate_aql_from_text(text_file_path, aql_file_path)

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post