0% found this document useful (0 votes)
2 views

ExamenProgramacion

The document outlines a Python script that processes a file specified by a command-line argument, utilizing modules like argparse and csv. It includes functionalities for reading, writing, and formatting data, while also handling potential errors such as FileNotFoundError and IndexError. Additionally, it checks file existence and size using the os module.

Uploaded by

aromeros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

ExamenProgramacion

The document outlines a Python script that processes a file specified by a command-line argument, utilizing modules like argparse and csv. It includes functionalities for reading, writing, and formatting data, while also handling potential errors such as FileNotFoundError and IndexError. Additionally, it checks file existence and size using the os module.

Uploaded by

aromeros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#import​ ​ ​ #Obtener

i.datetime​ ​ ​ ruta=sys.argv[1]
i.argparse​ ​ ​ rutaAll=sys.argv[1].strip(‘./\\’)
i.sys​ ​ ​ ​

#open
with open(ruta, ´r/w´, newline=‘ ’) as Nombre:
​ var = csv.DictReader/Writer(Nombre, fieldnames=cabeza)​

#Leer
for web in []:
web[“url”] = web[“urll”].replace(“ ‘ ”, “”)

#DataFormat
R.data = datetime.datetime.strptime(fecha, “%Y-%m-%d %H:%M:%S”)
W.data = datetime.datetime.now().date()

#Other
var.writeheader()
var.writerow({ “a”: var})

#Errors:
FileNotFoundError
IndexError
raise MiError

#ParserInfo
parser = parser = argparse.ArgumentParser()
parser.add_argument(“--path”, type=srt, help=”Tu ayuda”)
args = parser.parse_args()

#OS
os.path.exists(ruta)
ext = os.path.splitext(ruta)[1]
os.path.getsize(ruta)

#Other
var = var.read()
var.write()

You might also like