The Ship Data CLI is a command-line tool designed to analyze ship data. It allows users to perform various operations on a dataset of ships, such as printing the number of ships, listing ship names and countries, generating histograms of ship speeds, and visualizing ship locations on a map.
- Print number of ships: Displays the total count of ships in the dataset.
- Print names of all ships: Lists the names of all ships.
- Print countries of all ships: Lists the countries associated with each ship.
- Print unique countries of all ships: Displays unique countries from the dataset.
- Print count of ships by type: Shows the count of ships categorized by their types.
- Search for ships by name: Finds ships whose names contain a given query (case-insensitive).
- Create a histogram of ship speeds: Generates and saves a histogram of ship speeds.
- Draw a map of ship locations: Creates a map with markers for each ship's location and saves it as an HTML file.
- Python 3.x
matplotlib
libraryfolium
libraryload_data
module (must define theload_data
function that returns ship data)
You can install the required libraries using pip:
pip install matplotlib folium
-
Clone this repository:
git clone https://github.com/Vrana710/Titanic.git
-
Navigate to the project directory:
cd Titanic
-
Install the required libraries (if not already installed):
pip3 install matplotlib folium
-
Ensure that your dataset is available and correctly configured in the
load_data
module. -
Run the CLI application:
python titanic.py
-
Enter commands as prompted. Available commands are:
1
: Print number of ships2
: Print names of all ships3
: Print countries of all ships4
: Print unique countries of all ships5
: Print count of ships by type6 <name>
: Search for ships by name (replace<name>
with the query string)7
: Create a histogram of ship speeds8
: Draw a map of ship locationsexit
: Exit the program
-
The program will generate output based on your commands. For example, the histogram of ship speeds will be saved as
speed_histogram.png
, and the map of ship locations will be saved asships_map.html
.
Here’s an example of running the application and using some commands:
python titanic.py
Enter command: 1
There are 150 ships in the file.
Enter command: 2
Names of all the ships:
- Ship A
- Ship B
...
Enter command: 7
Speed histogram saved as 'speed_histogram.png'
Enter command: 8
Ship map saved as 'ships_map.html'
Enter command: exit
Exiting the program.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to open issues or submit pull requests. All contributions are welcome!
For any questions or suggestions, please reach out to ranavarsha710@gmail.com.