File size: 912 Bytes
4132f1f
d2b9031
 
4132f1f
72dd3ca
4132f1f
d2b9031
 
 
 
 
 
72dd3ca
 
 
7773ef1
 
 
 
 
 
 
d2b9031
 
 
 
 
 
 
 
 
72dd3ca
 
d2b9031
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests
import pandas as pd
import gradio as gr
import spaces

@spaces.GPU
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()