File size: 1,235 Bytes
b31bf5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed21d9a
b31bf5b
 
 
 
4bd368c
ed21d9a
b31bf5b
 
4bd368c
eae2950
 
 
 
 
b31bf5b
3dd561a
80d60fb
b31bf5b
e5dbe3b
b31bf5b
ed21d9a
 
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
35
36
37
38
39
40
# import gradio as gr
# import time

# def add_file(history, task_history, file):
#     time.sleep(10)
#     history = history + [((file.name,), None)]
#     task_history = task_history + [((file.name,), None)]
#     print(history)
#     print(task_history)
#     return history, task_history


# chatbot = gr.Chatbot(label='Qwen-VL-Chat', elem_classes="control-height", height=520)
# task_history = gr.State([])
# with gr.Blocks() as demo:
#     addfile_btn = gr.UploadButton("Upload", file_types=["image"])
#     addfile_btn.upload(add_file, [chatbot, task_history, addfile_btn], [chatbot, task_history], show_progress=True)

# demo.launch()


import gradio as gr
import pandas as pd

def upload_file(files):
    file_paths = [file.name for file in files]
    print(file_paths, file_paths[0][-3:])
    df = pd.read_csv(file_paths[0])
    print(df)
    df.to_csv('test1.csv')
    df.to_csv(file_paths[0].replace('.csv','_')+'test2.csv')
    print([file.name for file in files])
    return file_paths

with gr.Blocks() as demo:
    file_output = gr.File()
    upload_button = gr.UploadButton("Click to Upload an Image or Video File", file_types=[".csv"])
    upload_button.upload(upload_file, upload_button, file_output)

demo.launch()