mrcuddle commited on
Commit
12647e1
·
verified ·
1 Parent(s): 7237016

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -4,13 +4,14 @@ import requests
4
  import spaces
5
 
6
  @spaces.GPU
7
- def convert_parquet_to_jsonl(parquet_file_or_url):
8
- if parquet_file_or_url.startswith("http"):
9
- response = requests.get(parquet_file_or_url)
10
- parquet_file = response.content
 
 
11
  else:
12
- parquet_file = parquet_file_or_url.name
13
- df = pd.read_parquet(parquet_file)
14
  jsonl_data = df.to_json(orient='records', lines=True)
15
  return jsonl_data
16
 
 
4
  import spaces
5
 
6
  @spaces.GPU
7
+ def convert_parquet_to_jsonl(parquet_file=None, parquet_url=None):
8
+ if parquet_file is not None:
9
+ df = pd.read_parquet(parquet_file.name)
10
+ elif parquet_url is not None:
11
+ response = requests.get(parquet_url)
12
+ df = pd.read_parquet(response.content)
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