-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0068cd
commit c65e9c4
Showing
4 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
# This block is only evaluated by type checkers (and jupyter-repo2cwl). | ||
# Therefore, it is not executed when running hte notebook. | ||
# In other words, 'ipython2cwl' does not even need to be installed! | ||
from ipython2cwl.iotypes import CWLFilePathInput, CWLFilePathOutput | ||
|
||
import csv | ||
import json | ||
|
||
input_file: "CWLFilePathInput" = "data.csv" | ||
with open(input_file, mode="r", encoding="utf-8") as f: | ||
csv_reader = csv.reader(f) | ||
data = [line for line in csv_reader if line] | ||
|
||
headers = data[0] | ||
values = data[1:] | ||
items = [{k: v} for val in values for k, v in zip(headers, val)] | ||
|
||
output_file: "CWLFilePathOutput" = "output.json" | ||
with open(output_file, mode="w", encoding="utf-8") as f: | ||
json.dump(items, f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters