Skip to content

Commit 9e01e89

Browse files
committed
feat: implement barebones of inputting data
1 parent 4741dc6 commit 9e01e89

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

label_your_data_api/data_ops/ingress/ingress.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,44 @@
1-
def input_data():
1+
import zipfile
2+
import tarfile
3+
4+
5+
def input_data(file_name: str):
6+
data = None
7+
8+
# tar file
9+
if tarfile.is_tarfile(file_name):
10+
with tarfile.open(file_name, 'r') as tar:
11+
data = [member.name for member in tar.getmembers()
12+
if member.isfile()]
13+
# zip file
14+
elif zipfile.is_zipfile(file_name):
15+
with zipfile.ZipFile(file_name, 'r') as zipf:
16+
data = [info.filename for info in zipf.infolist()
17+
if not info.is_dir()]
18+
# single file
19+
else:
20+
with open(file_name, 'r') as file:
21+
data = file.read()
22+
23+
# TODO: save to db
24+
25+
print(data)
26+
27+
raise NotImplementedError
28+
29+
30+
def show_data(file_path: str):
31+
# Example: just call input_data for now
32+
return input_data(file_path)
33+
34+
# TODO: save to db
35+
36+
print(data)
37+
38+
raise NotImplementedError
39+
40+
41+
def show_data(file_path: str):
242
raise NotImplementedError
343

444

0 commit comments

Comments
 (0)