Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
IMPETOM-Clínico
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martina Barreiro Guerra
IMPETOM-Clínico
Commits
cefb71ad
Commit
cefb71ad
authored
2 years ago
by
Martina Barreiro Guerra
Browse files
Options
Downloads
Patches
Plain Diff
Delete Archivos.py
parent
f4163736
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
IMPETOM-Clínico/Archivos.py
+0
-61
0 additions, 61 deletions
IMPETOM-Clínico/Archivos.py
with
0 additions
and
61 deletions
IMPETOM-Clínico/Archivos.py
deleted
100644 → 0
+
0
−
61
View file @
f4163736
import
array
from
ImpetomCError
import
ImpetomCError
import
numpy
as
np
class
Archivos
:
"""
El objetivo de esta clase es poder implementar la lectura y escritura de archivos de texto
"""
def
__init__
(
self
,
nombre
):
"""
Creación del objeto archivo de texto.
:param nombre: Nombre del archivo de texto
:exception ImpetomCError: Devuelve una excepción indicando que el archivo no es un txt
"""
if
nombre
.
endswith
(
'
.txt
'
):
self
.
nombre
=
nombre
else
:
raise
ImpetomCError
(
"
El archivo de texto debe ser un txt
"
)
def
leerArchivo
(
self
):
"""
Permite la lectura de un archivo de texto con el formato de datos de ImpetomC. Es decir lee un archivo con 208 de números de tipo float
:returns: **medidas** - Retorna un vector con 208 valores de tipo float.
:exception ImpetomCError: En caso de que el archivo no tenga el formato esperado, devuelva una excepción.
"""
medidas
=
array
.
array
(
'
f
'
,[])
try
:
with
open
(
self
.
nombre
,
'
r
'
)
as
file
:
for
i
in
range
(
0
,
208
):
dato
=
float
(
file
.
readline
())
medidas
.
insert
(
i
,
dato
)
file
.
close
()
return
np
.
asarray
(
medidas
)
except
ValueError
:
raise
ImpetomCError
(
"
El archivo especificado no contiene datos con formato de ImpetomC
"
)
def
escribirArchivo
(
self
,
medidas
):
"""
Permite la escritura de un archivo de texto con las medidas realizadas por el dispositivo Impetom
:param medidas: vector de 208 medidas
:exception ImpetomCError: Devuelve un error indicando que el vector medidas no contine datos con el formato requerido
"""
if
len
(
medidas
)
!=
208
:
raise
ImpetomCError
(
"
El vector de entrada no contiene datos de impetomC
"
)
with
open
(
self
.
nombre
,
'
w
'
)
as
file
:
for
i
in
medidas
:
dato
=
str
(
i
)
+
"
\n
"
file
.
write
(
dato
)
file
.
close
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment