(args, idx, row)
| 55 | if '-' in i else [int(i)]) for i in s.split(',')), []) |
| 56 | |
| 57 | def unpack(args, idx, row): |
| 58 | #pprint(row) |
| 59 | |
| 60 | path = f"{args.target_path}/{idx}" |
| 61 | Path(path).mkdir(parents=True, exist_ok=True) |
| 62 | |
| 63 | # all items are text, except 'image' |
| 64 | |
| 65 | img = row["image"] |
| 66 | basename = f"{path}/image" |
| 67 | ext = "null" if img is None else "jpg" |
| 68 | file = f"{basename}.{ext}" |
| 69 | with open(file, "w") as fh: |
| 70 | if img is not None: |
| 71 | img.save(fh, 'jpeg') |
| 72 | |
| 73 | for col in ['meta', 'source', 'text']: |
| 74 | item = row[col] |
| 75 | basename = f"{path}/{col}" |
| 76 | ext = "null" if item is None else "txt" |
| 77 | file = f"{basename}.{ext}" |
| 78 | with open(file, "w") as fh: |
| 79 | if item is not None: |
| 80 | fh.write(item) |
| 81 | |
| 82 | def dump_example_shapes(idx, row): |
| 83 | """ dump the row stats """ |
no test coverage detected