Hello guys,
I'm using the following code in order to collect the cancelled flights from some airlines:
My best output would be something like this:
Thank you guys.
I'm using the following code in order to collect the cancelled flights from some airlines:
import pandas as pd url_ini = 'https://flightaware.com/live/fleet/' url_fim = '/cancelled' ncia = ['SKU', 'TAM'] for i in range(len(ncia)): url = url_ini + str(ncia[i]) + url_fim df = pd.read_html(url)[3] df.to_csv(r'C:\Users\bruno\Desktop\Teste.txt', sep=';', mode='a', header=None, encoding = 'utf-8', index=False) print('Atualizado apra a ' + str(ncia[i]) )And the output is something like this:
Output:SKU326;A320;Int'l Comodoro Arturo Merino Benítez (SCL / SCEL);Int'l Diego Aracena (IQQ / SCDA);Sex 17:43 -04;;;
SKU250;A320;Int'l Comodoro Arturo Merino Benítez (SCL / SCEL);Int'l El Loa (CJC / SCCF);Sex 18:29 -04;;;
SKU801;A320;Jorge Chávez Int'l (LIM / SPJC);Int'l Comodoro Arturo Merino Benítez (SCL / SCEL);Sex 17:44 -05;;;
SKU329;A320;Int'l Diego Aracena (IQQ / SCDA);Int'l Comodoro Arturo Merino Benítez (SCL / SCEL);Sex 20:47 -04;;;
SKU253;A320;Int'l El Loa (CJC / SCCF);Int'l Comodoro Arturo Merino Benítez (SCL / SCEL);Sex 21:11 -04;;;
SKU433;A320;Int'l Comodoro Arturo Merino Benítez (SCL / SCEL);El Tepual Int'l (PMC / SCTE);Sáb 10:55 -04;;;
But I would like to better organize my data and split the content from column 2 and 3, ("Int'l Comodoro Arturo Merino Benítez (SCL / SCEL)" and "Int'l Diego Aracena (IQQ / SCDA)") to just SCL IQQ. So basically I just need the airport code, I don't need the airport name.My best output would be something like this:
Output:SKU326;A320;SCL;IQQ;Sex 17:43 -04;;;
SKU250;A320;SCL;CJC;Sex 18:29 -04;;;
SKU801;A320;LIM;SCL;Sex 17:44 -05;;;
SKU329;A320;IQQ);SCL;Sex 20:47 -04;;;
SKU253;A320;CJC;SCL;Sex 21:11 -04;;;
SKU433;A320;SCL;PMC;Sáb 10:55 -04;;;
How can I do that?Thank you guys.