AR-X commited on
Commit
036547d
·
verified ·
1 Parent(s): a903b39

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -8
README.md CHANGED
@@ -112,19 +112,23 @@ Example:
112
  These parts correspond to a single original archive. You can merge them into a single folder using Python:
113
 
114
  ```python
115
- import zipfile
116
  from pathlib import Path
117
 
118
  sequence_dir = Path("SynLiDAR/FullDataset/sequences")
119
- parts = sorted(sequence_dir.glob("06_part*.zip"))
 
120
 
121
- output = Path("merged_06")
122
- output.mkdir(exist_ok=True)
 
123
 
124
- for z in parts:
125
- print("Extracting", z.name)
126
- with zipfile.ZipFile(z, "r") as zp:
127
- zp.extractall(output)
 
 
 
128
  ```
129
 
130
 
 
112
  These parts correspond to a single original archive. You can merge them into a single folder using Python:
113
 
114
  ```python
 
115
  from pathlib import Path
116
 
117
  sequence_dir = Path("SynLiDAR/FullDataset/sequences")
118
+ # find bases that have part files
119
+ bases = sorted({p.stem.split("_part")[0] for p in sequence_dir.glob("*_part*.zip")})
120
 
121
+ for base in bases:
122
+ parts = sorted(sequence_dir.glob(f"{base}_part*.zip"))
123
+ output_zip = sequence_dir / f"{base}.zip"
124
 
125
+ print(f"[{base}] merging {len(parts)} parts -> {output_zip}")
126
+ with open(output_zip, "wb") as out:
127
+ for p in parts:
128
+ with open(p, "rb") as f:
129
+ out.write(f.read())
130
+
131
+ print("All sequences merged.")
132
  ```
133
 
134