Python Forum
Trying to Tabulate Information from an Aircraft Website Link(s)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to Tabulate Information from an Aircraft Website Link(s)
#1
Hi There,

I am trying to Tabulate Information from an RAF Aircraft Website Schedule.

I would like only the appearances, that are displays, and only showing those, that have the Spitfire Hurricane and Dakota booked, in table form. Either for each Individual month, or for the year as a whole i.e. 2007.

For example for September the Website Link is :-

http://web.archive.org/web/2007070113381...ber07.html

And each of the Months Website Link is different, by only the month name i.e. march07.html

august07.html etc.

Can someone help me with my code :-

I used the September Website Link as an attempt, to tabulate the Webpage Data. But the data didn't display correctly, when I ran the Code, any help would be much appreciated.

Here is the Code :-

import pandas as pd
import requests
from bs4 import BeautifulSoup
from tabulate import tabulate

res = requests.get("http://web.archive.org/web/20070701133815/http://www.bbmf.co.uk/september07.html")
soup = BeautifulSoup(res.content,'lxml')
table = soup.find_all('table')[0] 
df = pd.read_html(str(table))
print( tabulate(df[0], headers='keys', tablefmt='psql') )
Regards

Eddie Winch
Reply
#2
So it's still Aircrafts eddy Cool
And i guess still little Python.

You are mixing up some stuff here,drop tabulate and do all in pandas.
You pretty much need Jupyter Notebook,this make display of table and testing a whole lot simpler.

I have done some testing look at this notebook
See that display of table is good in notebook.

Done some comparing,all Location that had Spitfire in program.
df = df[(df['Location'] != "") & (df['Spitfire'] == 'S')]
So in September had Boston two display of Spitfire.
df[(df['Location'] == 'Boston') & (df['Spitfire'] == 'S')]
Output:
Location Spitfire 57 Boston S 76 Boston S
Reply
#3
Many thanks for your help snippsat,

I only want to the table to show the Venues, having displays, and that have the Spitfire Hurricane and Dakota booked,I want all the others not to be shown. Also how could I have a Table just showing, all of the Spitfire Hurricane and Dakota booked displays i.e. SHD only, for the whole year, altogether ?

Regards

Eddie Winch
Reply
#4
Also how do you get Jupyter working ? I am not sure how to use it ?
Reply
#5
(Jun-16-2019, 08:31 PM)eddywinch82 Wrote: Also how do you get Jupyter working ? I am not sure how to use it ?
Installing Jupyter
I think you used Windows.
# Check pip
G:\1_bilder\forum
λ pip -V
pip 19.1.1 from c:\python37\lib\site-packages\pip (python 3.7)

# Install
G:\1_bilder\forum
λ pip install jupyter
Collecting jupyter
  Downloading .....

# Start Notebook
G:\1_bilder\forum
λ jupyter notebook
Try get up and running,see if understand how i get filtered result for September.
For whole year most loop over pages and collect wanted result.
Reply
#6
Hi snippsat,

I finally got Jupyter Notebook, working last night. How do you run Python Code, in Jupyter Notebook ?

df = df[(df['Location'] != "") & (df['Spitfire'] == 'S')]
The above Code you typed for me, is showing all Locations, that have a Spitfire booked.

What would I type, to only show all Locations, that were having displays only i.e. Lydd - Display. And that only, had the Spitfire Hurricane and Dakota booked. I can see what you are doing there, in the coding. When typing the whole code, is it typed in the order, it is displayed as, in your Notebook ?

Eddie

Many thanks buran, for sorting that out for me.
Reply
#7
(Jun-17-2019, 12:58 PM)eddywinch82 Wrote: I finally got Jupyter Notebook, working last night. How do you run Python Code, in Jupyter Notebook ?
When it start in browser,image under choice python 3.
[Image: x8tvVj.jpg]
Quote:When typing the whole code, is it typed in the order, it is displayed as, in your Notebook ?
Yes run one cell and display output.
Quote:What would I type, to only show all Locations, that were having displays only i.e. Lydd - Display. And that only, had the Spitfire Hurricane and Dakota booked.
Look at this Notebook.
Here you get a clean up Dataframe and can do test with data as i show under.
Is your task so now that you have gotten start help show some effort,i am not gone write all code Snooty
Search for tutorials Pandas/NoteBook there are a lot out there.
Reply
#8
Thanks for your help snippsat,

I have a problem, where when I copy text, and try to Paste the Text, in a new Jupyter Notebook, Python3 Section Cell, the option to Paste is greyed out. Is there a way of fixing this ? Did you have the same issue ? According to posts on the internet, other people have had the same problem.

Eddie
Reply
#9
(Jun-17-2019, 06:01 PM)eddywinch82 Wrote: I have a problem, where when I copy text, and try to Paste the Text, in a new Jupyter Notebook, Python3 Section Cell, the option to Paste is greyed out.
Are you taking about my Notebook?
That's a static Notebook made with nbviewer only for share code/data.
The field will be greyed as you it's only a Notebook for display of what i have done.
You have to copy content over to your Notebook and run it.
Reply
#10
"You have to copy content over to your Notebook and run it."

Thats what I tried to do, I meant copying text, and trying to paste in a new Notebook, in Jupyter Notebook but the option to paste text is greyed out.

Eddie
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to insert Dashed Lines in between Rows of a tabulate output Mudassir1987 0 495 Sep-27-2023, 10:09 AM
Last Post: Mudassir1987
  pandas, tabulate, and alignment menator01 3 7,246 Feb-05-2022, 07:04 AM
Last Post: menator01
  display the result of Dataframe in tabulate format alex80 0 1,385 Sep-09-2020, 02:22 PM
Last Post: alex80
  How to tabulate correctly repeated blocks? Xiesxes 4 2,927 Mar-21-2020, 04:57 PM
Last Post: Xiesxes
  Obtain Geometric Information and name from a map-design website fyec 2 2,421 Aug-08-2018, 05:11 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020