This repository has been archived by the owner on Dec 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dallas/blo-151-afg31000' of https://github.com/flojoy-a…
…i/blocks into dallas/blo-151-afg31000
- Loading branch information
Showing
390 changed files
with
17,969 additions
and
1,471 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
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
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
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
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
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
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
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,58 @@ | ||
import pandas as pd | ||
import os | ||
from flojoy import ( | ||
DataFrame, | ||
OrderedPair, | ||
OrderedTriple, | ||
Matrix, | ||
flojoy, | ||
DataContainer, | ||
Directory, | ||
) | ||
from typing import Optional | ||
|
||
|
||
@flojoy | ||
def EXPORT_CSV( | ||
dc: OrderedPair | OrderedTriple | DataFrame | Matrix, | ||
dir: Directory, | ||
filename: str = "exported.csv", | ||
) -> Optional[DataContainer]: | ||
"""Export a DataContainer into CSV format. | ||
Parameters | ||
---------- | ||
dc : OrderedPair|OrderedTriple|DataFrame | ||
The DataContainer to export. | ||
dir : Directory | ||
The directory to export to. | ||
filename : str | ||
The name of the file to output. | ||
Returns | ||
------- | ||
None | ||
""" | ||
|
||
if dir is None: | ||
raise ValueError("Please select a directory to export the data to") | ||
|
||
path = os.path.join(dir.unwrap(), filename) | ||
|
||
match dc: | ||
case OrderedPair() | OrderedTriple(): | ||
df = pd.DataFrame(dc) | ||
df = df.drop(columns=["type", "extra"]) | ||
df.to_csv(path, index=False) | ||
case DataFrame(): | ||
df = dc.m | ||
df.to_csv(path, index=False) | ||
case Matrix(): | ||
df = pd.DataFrame(dc.m) | ||
df.to_csv(path, index=False, header=False) | ||
case _: | ||
raise ValueError( | ||
f"Invalid DataContainer type: {dc.type} cannot be exported as CSV." | ||
) | ||
|
||
return None |
Oops, something went wrong.