tresdtres commited on
Commit
fde71fd
·
1 Parent(s): 2eb963e

Upload Recursive_Wildcard_Modifier.ipynb

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