- Blog/
Using Nushell 🐘 with Generative Artificial Intelligence 🤖
·1268 words·6 mins
Table of Contents
Requirements #
Mission #
Know a little about each large city in India
Solution #
http get https://en.wikipedia.org/wiki/List_of_cities_in_India_by_population |
query web --as-table [City 'Population(2011)[3]' 'Population(2001)[3][a]' 'State or unionterritory' 'Ref'] |
select City |
insert desc {|row| $row.City |
aichat 'provide ultra short description of this city' } |
save cities.json
Explanation #
- The first line gets the web page from Wikipedia
- The second converts the html table into Nushell table format
- The third selects the City column
- The fourth creates a new column called ‘desc’
- The fifth feeds city names row by row to aichat with my instruction
- The sixth saves the result in json format
Result #
Now each city has a short description appended:
[
{
"City": "Mumbai",
"desc": "India's bustling financial hub and entertainment capital, Mumbai is a diverse metropolis known for its iconic Bollywood industry, historic landmarks, and vibrant street life.\n"
},
{
"City": "Delhi",
"desc": "India's capital, historical landmarks, diverse culture, political hub.\n"
},
{
"City": "Bangalore",
"desc": "Bangalore, also known as Bengaluru, is the capital of Karnataka, India, known for its IT industry and pleasant climate.\n"
},
{
"City": "Hyderabad",
"desc": "Capital of Telangana, India; known for biryani, technology industry, Charminar, and pearl trading.\n"
},
{
"City": "Ahmedabad",
"desc": "Ahmedabad is a vibrant Indian city known for its textiles, rich history, and the Sabarmati Ashram associated with Mahatma Gandhi.\n"
},
{
"City": "Chennai",
"desc": "Coastal South Indian city known for its cultural heritage, IT industry, and Marina Beach.\n"
},
{
"City": "Kolkata ",
"desc": "Kolkata: Cultural capital of India; historical city with colonial architecture, vibrant arts scene, and notable intellectual heritage.\n"
},
{
"City": "Surat",
"desc": "Surat is a bustling port city in the Indian state of Gujarat known for its diamond cutting and textile industries.\n"
},
{
"City": "Pune",
"desc": "Pune is a vibrant educational and IT hub in western India known for its historical landmarks and cultural diversity.\n"
},
{
"City": "Jaipur",
"desc": "Jaipur, also known as the Pink City, is the capital of Rajasthan in India, known for its rich history, stunning palaces, and vibrant culture.\n"
},
{
"City": "Lucknow",
"desc": "Capital of Uttar Pradesh, known for its Nawabi era history and exquisite cuisine, particularly kebabs and biryanis.\n"
},
{
"City": "Kanpur",
"desc": "Kanpur: Industrial city on the Ganges in Uttar Pradesh, India, known for textiles and leather.\n"
},
{
"City": "Nagpur",
"desc": "Nagpur is a major city in Maharashtra, India, known for its oranges and as a political and commercial hub in central India.\n"
},
{
"City": "Indore",
"desc": "Indore is a bustling, commercial city in central India, known for its culinary scene, historical landmarks, and as the education hub of the state of Madhya Pradesh.\n"
},
{
"City": "Thane",
"desc": "Thane is a bustling city adjacent to Mumbai in Maharashtra, India, known for its lakes and the ancient Masunda Lake temple complex.\n"
},
{
"City": "Bhopal",
"desc": "Bhopal is the capital city of the Indian state of Madhya Pradesh, known for its lakes, greenery, and rich history, including the Bhopal gas tragedy.\n"
},
{
"City": "Visakhapatnam",
"desc": "Visakhapatnam: Indian coastal city, port hub, industrial center, and scenic beauty in Andhra Pradesh.\n"
},
{
"City": "Pimpri-Chinchwad",
"desc": "Pimpri-Chinchwad: Industrial city in Maharashtra, India, known for its automotive and manufacturing industries, part of Pune Metropolitan Region.\n"
},
{
"City": "Patna",
"desc": "Capital of Bihar, India; ancient city on the Ganges River.\n"
},
{
"City": "Vadodara",
"desc": "Vadodara, formerly known as Baroda, is a culturally-rich city in the Indian state of Gujarat, known for its palaces, parks, temples, and educational institutions.\n"
},
{
"City": "Ghaziabad",
"desc": "Ghaziabad is a rapidly urbanizing city in the Indian state of Uttar Pradesh, part of the National Capital Region, known for its industrial growth and proximity to New Delhi.\n"
},
{
"City": "Ludhiana",
"desc": "Ludhiana: Industrial city in Punjab, India, known for hosiery, textiles, and light engineering.\n"
},
{
"City": "Agra",
"desc": "Agra: Indian city, home to the Taj Mahal.\n"
},
{
"City": "Nashik",
"desc": "Nashik: Indian city known for temples, vineyards, Kumbh Mela festival, and as a Hindu pilgrimage site near the Godavari River.\n"
},
{
"City": "Faridabad",
"desc": "Faridabad is an industrial city in the northern Indian state of Haryana, part of the National Capital Region near New Delhi.\n"
},
{
"City": "Meerut",
"desc": "Meerut is a historical city in the Indian state of Uttar Pradesh, known for its role in the 1857 First War of Indian Independence and as a hub for sports goods manufacturing.\n"
},
{
"City": "Rajkot",
"desc": "Rajkot is a vibrant city in the Indian state of Gujarat, known for its history, textile industry, and Gandhi-related landmarks.\n"
},
{
"City": "Kalyan-Dombivali",
"desc": "Kalyan-Dombivali is a twin city and a municipal corporation in the Thane district of Maharashtra, India, part of the Mumbai Metropolitan Region known for its residential areas and rapidly developing infrastructure.\n"
},
{
"City": "Vasai-Virar",
"desc": "Vasai-Virar is a rapidly urbanizing city in the Mumbai Metropolitan Region of Maharashtra, India, known for its cultural heritage and growing infrastructure.\n"
},
{
"City": "Varanasi",
"desc": "Ancient holy city on the Ganges in India, known for spirituality, ghats, and temples.\n"
},
{
"City": "Srinagar",
"desc": "Srinagar is the summer capital of Jammu and Kashmir, India, known for its beautiful lakes, houseboats, and gardens.\n"
},
{
"City": "Aurangabad",
"desc": "Aurangabad is a historic city in Maharashtra, India, known for its medieval monuments, including the UNESCO World Heritage Sites of Ajanta and Ellora caves.\n"
},
{
"City": "Dhanbad",
"desc": "Dhanbad is an Indian city known for coal mining and industrial activities, located in Jharkhand state.\n"
},
{
"City": "Amritsar",
"desc": "Sikh holy city, Golden Temple, Punjab region, India.\n"
},
{
"City": "Navi Mumbai",
"desc": "Planned satellite city of Mumbai, India, with modern infrastructure and rapid urban growth.\n"
},
{
"City": "Prayagraj",
"desc": "Prayagraj, formerly known as Allahabad, is a historic city in Uttar Pradesh, India, renowned for its confluence of three rivers: the Ganges, Yamuna, and mythical Saraswati, making it a pivotal site for Hindu pilgrimages.\n"
},
{
"City": "Howrah",
"desc": "Howrah is an industrial city located in the Indian state of West Bengal, featuring the iconic Howrah Bridge and serving as a transportation hub adjacent to Kolkata.\n"
},
{
"City": "Ranchi",
"desc": "Ranchi is the capital of the Indian state of Jharkhand, known for its waterfalls, tribal heritage, and rich mineral resources.\n"
},
{
"City": "Jabalpur",
"desc": "Jabalpur: A historic Indian city known for marble rock formations along the Narmada River, with significant cultural heritage and military bases.\n"
},
{
"City": "Gwalior",
"desc": "Gwalior is a historic city in central India, known for its majestic hilltop fort, rich cultural heritage, and classical music tradition.\n"
},
{
"City": "Coimbatore",
"desc": "Coimbatore is a bustling industrial city in the southern Indian state of Tamil Nadu, known for its textile industry, manufacturing, pleasant weather, and proximity to hill stations like Ooty.\n"
},
{
"City": "Vijayawada",
"desc": "Vijayawada: Major city in Andhra Pradesh, India, known for the Krishna River and canal network.\n"
},
{
"City": "Jodhpur",
"desc": "Jodhpur: Indian city, known as the \"Blue City\", famous for its historic Mehrangarh Fort and vibrant culture.\n"
},
{
"City": "Madurai",
"desc": "Ancient temple city in Tamil Nadu, India, known for the Meenakshi Amman Temple.\n"
},
{
"City": "Raipur",
"desc": "Raipur is the capital city of the Indian state of Chhattisgarh, known for its steel industries and educational institutions.\n"
},
{
"City": "Kota",
"desc": "Kota: An educational hub in Rajasthan, India known for its coaching centers for competitive exam preparations and the Chambal river.\n"
}
]
That would have taken a long time to do manually.