Muevo image.json a carpeta images, actualizo .gitignore y ajusto nombres de atributos
Browse files- .gitignore +1 -1
- images.json → images/images.json +2 -2
- main.py +2 -2
.gitignore
CHANGED
@@ -1 +1 @@
|
|
1 |
-
images
|
|
|
1 |
+
images/*[!.json]
|
images.json → images/images.json
RENAMED
@@ -1,11 +1,11 @@
|
|
1 |
{
|
2 |
"imagesToUpload": [
|
3 |
{
|
4 |
-
"
|
5 |
"text": "<value>"
|
6 |
},
|
7 |
{
|
8 |
-
"
|
9 |
"text": "<value>"
|
10 |
}
|
11 |
]
|
|
|
1 |
{
|
2 |
"imagesToUpload": [
|
3 |
{
|
4 |
+
"name": "<image-file>",
|
5 |
"text": "<value>"
|
6 |
},
|
7 |
{
|
8 |
+
"name": "<image-file>",
|
9 |
"text": "<value>"
|
10 |
}
|
11 |
]
|
main.py
CHANGED
@@ -9,12 +9,12 @@ df = table.to_pandas() # DataFrame
|
|
9 |
|
10 |
print("INICIO", df)
|
11 |
|
12 |
-
with open("images.json") as json_file:
|
13 |
data = json.load(json_file)
|
14 |
image_rows = data["imagesToUpload"]
|
15 |
|
16 |
for img in image_rows:
|
17 |
-
image_path = img["
|
18 |
image_text = img["text"]
|
19 |
with open(image_path, "rb") as image:
|
20 |
image_bytes = image.read()
|
|
|
9 |
|
10 |
print("INICIO", df)
|
11 |
|
12 |
+
with open("images/images.json") as json_file:
|
13 |
data = json.load(json_file)
|
14 |
image_rows = data["imagesToUpload"]
|
15 |
|
16 |
for img in image_rows:
|
17 |
+
image_path = f"images/{img["name"]}"
|
18 |
image_text = img["text"]
|
19 |
with open(image_path, "rb") as image:
|
20 |
image_bytes = image.read()
|