Spaces:
Running
Running
import requests | |
import pandas as pd | |
import gradio as gr | |
import spaces | |
def download_file(url): | |
response = requests.get(url) | |
return response.content | |
def convert_parquet_to_jsonl(parquet_file): | |
df = pd.read_parquet(parquet_file) | |
jsonl_data = df.to_json(orient='records', lines=True) | |
return jsonl_data | |
def main(url): | |
parquet_file = download_file(url) | |
jsonl_data = convert_parquet_to_jsonl(parquet_file) | |
with open("output.jsonl", "w") as f: | |
f.write(jsonl_data) | |
return "output.jsonl" | |
def gradio_interface(): | |
demo = gr.Interface( | |
fn=main, | |
inputs=[gr.Textbox(label="Parquet File URL")], | |
outputs=[gr.File(label="JSONL Output")], | |
title="Parquet to JSONL Converter", | |
description="Convert a Parquet file to JSONL format from a downloadable link" | |
) | |
demo.launch() | |
if __name__ == "__main__": | |
gradio_interface() |