Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,15 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import pandas as pd
|
| 3 |
import requests
|
|
|
|
|
|
|
| 4 |
import spaces
|
| 5 |
|
| 6 |
@spaces.GPU
|
| 7 |
-
def
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
else:
|
| 14 |
-
raise ValueError("Either parquet_file or parquet_url must be provided")
|
| 15 |
jsonl_data = df.to_json(orient='records', lines=True)
|
| 16 |
return jsonl_data
|
| 17 |
|
|
@@ -22,15 +20,15 @@ def main(url):
|
|
| 22 |
f.write(jsonl_data)
|
| 23 |
return "output.jsonl"
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
)
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import gradio as gr
|
| 4 |
import spaces
|
| 5 |
|
| 6 |
@spaces.GPU
|
| 7 |
+
def download_file(url):
|
| 8 |
+
response = requests.get(url)
|
| 9 |
+
return response.content
|
| 10 |
+
|
| 11 |
+
def convert_parquet_to_jsonl(parquet_file):
|
| 12 |
+
df = pd.read_parquet(parquet_file)
|
|
|
|
|
|
|
| 13 |
jsonl_data = df.to_json(orient='records', lines=True)
|
| 14 |
return jsonl_data
|
| 15 |
|
|
|
|
| 20 |
f.write(jsonl_data)
|
| 21 |
return "output.jsonl"
|
| 22 |
|
| 23 |
+
def gradio_interface():
|
| 24 |
+
demo = gr.Interface(
|
| 25 |
+
fn=main,
|
| 26 |
+
inputs=[gr.Textbox(label="Parquet File URL")],
|
| 27 |
+
outputs=[gr.File(label="JSONL Output")],
|
| 28 |
+
title="Parquet to JSONL Converter",
|
| 29 |
+
description="Convert a Parquet file to JSONL format from a downloadable link"
|
| 30 |
+
)
|
| 31 |
+
demo.launch()
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|
| 34 |
+
gradio_interface()
|