Saboorhsn commited on
Commit
08e2876
·
verified ·
1 Parent(s): 833a07b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
2
  from datasets import load_dataset, concatenate_datasets
3
  import json
4
  import os
5
- import base64 # Add base64 for encoding
6
 
7
  def load_and_combine_datasets():
8
  python_codes_dataset = load_dataset('flytech/python-codes-25k', split='train')
@@ -42,11 +42,17 @@ def main():
42
  file_path = os.path.join(os.getcwd(), f"{output_dataset_name}.jsonl")
43
  save_combined_dataset_as_jsonl(combined_dataset, file_path)
44
  st.write("Download the combined dataset as JSONL file:")
45
- with open(file_path, "r") as f: # Open file in read mode
46
- bytes_data = f.read().encode() # Encode the data as bytes
47
  b64 = base64.b64encode(bytes_data).decode()
48
  href = f'<a href="data:file/jsonl;base64,{b64}" download="{output_dataset_name}.jsonl">Download JSONL File</a>'
49
  st.markdown(href, unsafe_allow_html=True)
 
 
 
 
 
 
50
 
51
  if __name__ == "__main__":
52
  main()
 
2
  from datasets import load_dataset, concatenate_datasets
3
  import json
4
  import os
5
+ import base64
6
 
7
  def load_and_combine_datasets():
8
  python_codes_dataset = load_dataset('flytech/python-codes-25k', split='train')
 
42
  file_path = os.path.join(os.getcwd(), f"{output_dataset_name}.jsonl")
43
  save_combined_dataset_as_jsonl(combined_dataset, file_path)
44
  st.write("Download the combined dataset as JSONL file:")
45
+ with open(file_path, "r") as f:
46
+ bytes_data = f.read().encode()
47
  b64 = base64.b64encode(bytes_data).decode()
48
  href = f'<a href="data:file/jsonl;base64,{b64}" download="{output_dataset_name}.jsonl">Download JSONL File</a>'
49
  st.markdown(href, unsafe_allow_html=True)
50
+
51
+ # Provide download button
52
+ st.download_button(label="Click to Download",
53
+ data=bytes_data,
54
+ file_name=f"{output_dataset_name}.jsonl",
55
+ mime="application/jsonl")
56
 
57
  if __name__ == "__main__":
58
  main()