Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addresses #2785 Automatically pull in HuBMAP 2D images #2805

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/scripts/2D_FTU_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import requests

# Define the API URL
API_URL = "https://grlc.io/api-git/hubmapconsortium/ccf-grlc/subdir/hra/ftu-parts"

# Function to fetch CSV data from the API and save it directly to a file
def fetch_and_save_csv(url, output_file):
headers = {"Accept": "text/csv"} # Request CSV format
response = requests.get(url, headers=headers)
if response.status_code == 200:
# Write the CSV data directly to the output file
with open(output_file, mode='w', newline='', encoding='utf-8') as file:
file.write(response.text)
print(f"CSV data saved to {output_file}")
else:
print(f"Failed to fetch data from the API. Status code: {response.status_code}")

# Main execution
def main():
output_file = "robot_template.csv"
print(f"Fetching and saving CSV template to {output_file}...")
fetch_and_save_csv(API_URL, output_file)

if __name__ == "__main__":
main()