tresdtres commited on
Commit
ad031e2
·
1 Parent(s): 240211e

Upload Colab__Recursive_Wildcard_Modifier.ipynb

Browse files
Colab__Recursive_Wildcard_Modifier.ipynb ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "source": [
6
+ "pip install gradio"
7
+ ],
8
+ "metadata": {
9
+ "id": "XXpxfm6LVCKs"
10
+ },
11
+ "id": "XXpxfm6LVCKs",
12
+ "execution_count": null,
13
+ "outputs": []
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": null,
18
+ "id": "8bca37d5",
19
+ "metadata": {
20
+ "id": "8bca37d5",
21
+ "outputId": "05ca5b44-7aa2-438c-d803-d2fff1bd802a"
22
+ },
23
+ "outputs": [
24
+ {
25
+ "name": "stdout",
26
+ "output_type": "stream",
27
+ "text": [
28
+ "Running on local URL: http://127.0.0.1:7861\n",
29
+ "\n",
30
+ "To create a public link, set `share=True` in `launch()`.\n"
31
+ ]
32
+ },
33
+ {
34
+ "data": {
35
+ "text/html": [
36
+ "<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
37
+ ],
38
+ "text/plain": [
39
+ "<IPython.core.display.HTML object>"
40
+ ]
41
+ },
42
+ "metadata": {},
43
+ "output_type": "display_data"
44
+ }
45
+ ],
46
+ "source": [
47
+ "import gradio as gr\n",
48
+ "\n",
49
+ "# Resto del código...\n",
50
+ "\n",
51
+ "def editar_archivo(archivo, texto_inicio, texto_fin, ruta_guardado):\n",
52
+ " with open(archivo.name, 'r') as f:\n",
53
+ " lines = f.readlines()\n",
54
+ "\n",
55
+ " with open(ruta_guardado, 'w') as f:\n",
56
+ " for line in lines:\n",
57
+ " line = texto_inicio + line.strip() + texto_fin # Modifica la línea con el texto de inicio y fin\n",
58
+ " f.write(line + '\\n') # Escribe la línea modificada en el archivo de salida\n",
59
+ "\n",
60
+ "def interfaz():\n",
61
+ " archivo = gr.File(label=\"Input file *.txt\")\n",
62
+ " texto_inicio = gr.Textbox(label=\"Text at the beginning\")\n",
63
+ " texto_fin = gr.Textbox(label=\"Text at the end\")\n",
64
+ " ruta_guardado = gr.Textbox(label=\"Save path and filename *.txt\")\n",
65
+ " boton = gr.Button(label=\"edit file\")\n",
66
+ " gr.Interface(fn=editar_archivo, inputs=[archivo, texto_inicio, texto_fin, ruta_guardado], outputs=None, title=\"Recursive Wildcard Modifier\").launch(share=True)\n",
67
+ "\n",
68
+ "interfaz()\n",
69
+ "\n"
70
+ ]
71
+ },
72
+ {
73
+ "cell_type": "code",
74
+ "execution_count": null,
75
+ "id": "0501137d",
76
+ "metadata": {
77
+ "id": "0501137d"
78
+ },
79
+ "outputs": [],
80
+ "source": []
81
+ },
82
+ {
83
+ "cell_type": "code",
84
+ "execution_count": null,
85
+ "id": "ac8be353",
86
+ "metadata": {
87
+ "id": "ac8be353"
88
+ },
89
+ "outputs": [],
90
+ "source": []
91
+ }
92
+ ],
93
+ "metadata": {
94
+ "kernelspec": {
95
+ "display_name": "Python 3 (ipykernel)",
96
+ "language": "python",
97
+ "name": "python3"
98
+ },
99
+ "language_info": {
100
+ "codemirror_mode": {
101
+ "name": "ipython",
102
+ "version": 3
103
+ },
104
+ "file_extension": ".py",
105
+ "mimetype": "text/x-python",
106
+ "name": "python",
107
+ "nbconvert_exporter": "python",
108
+ "pygments_lexer": "ipython3",
109
+ "version": "3.10.9"
110
+ },
111
+ "colab": {
112
+ "provenance": []
113
+ }
114
+ },
115
+ "nbformat": 4,
116
+ "nbformat_minor": 5
117
+ }