Skip to content

Commit

Permalink
update io
Browse files Browse the repository at this point in the history
  • Loading branch information
vichayturen committed Jan 24, 2024
1 parent 5b74f6d commit 31eeedc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 打包tag上传到github
```shell
export new_tag=v0.0.1
export new_tag=v1.1.4
git tag $new_tag
git push origin $new_tag
```
Expand Down
8 changes: 4 additions & 4 deletions src/vutils/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ def jsonload(path: str):

def jsondump(data, path: str):
pre_dir, file = os.path.split(path)
if not os.path.exists(pre_dir):
if pre_dir != "" and not os.path.exists(pre_dir):
os.makedirs(pre_dir)
with open(path, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=4)

def jsonldump(data: List[dict], path: str) -> None:
pre_dir, file = os.path.split(path)
if not os.path.exists(pre_dir):
if pre_dir != "" and not os.path.exists(pre_dir):
os.makedirs(pre_dir)
jsonlines = []
for d in data:
Expand All @@ -36,7 +36,7 @@ def jsonlload(path: str) -> list:

def txtdump(data, path: str):
pre_dir, file = os.path.split(path)
if not os.path.exists(pre_dir):
if pre_dir != "" and not os.path.exists(pre_dir):
os.makedirs(pre_dir)
with open(path, 'w', encoding='utf-8') as f:
f.write(data)
Expand All @@ -56,7 +56,7 @@ def csvload(path: str) -> list:

def csvdump(data: list, path: str) -> None:
pre_dir, file = os.path.split(path)
if not os.path.exists(pre_dir):
if pre_dir != "" and not os.path.exists(pre_dir):
os.makedirs(pre_dir)
with open(path, 'w', encoding='utf-8', newline='') as f:
writer = csv.writer(f)
Expand Down

0 comments on commit 31eeedc

Please sign in to comment.