![5 ChatGPT features to boost your daily work](https://technicalterrence.com/wp-content/uploads/2023/05/5-ChatGPT-features-to-boost-your-daily-work.png)
Image by publisher
ChatGPT has completely changed the way of developing code. However, most software developers and data professionals still don’t use ChatGPT to enhance and facilitate their work.
That is why I describe here 5 different features to increase both speed and quality in your daily work.
You can use them in your daily work. Let’s find out together how 👇🏻
⚠️ Warning: You should never use critical code or information with ChatGPT.
ChatGPT is my secret weapon when it comes to building new projects from scratch. With just a few prompts, I can generate a skeleton of the code I need, complete with my chosen technologies, frameworks, and versions. Not only does it save me at least an hour of work each timebut it also helps to keep my documentation, or that of the team, organized and updated. It’s like having an extra pair of hands on your team!
For example, imagine that I want to use some external API. I can ask ChatGPT to write an initial code structure for me.
Generate boilerplate code that integrates an external API using Python.
And ChatGPT responds immediately:
Screenshot ChatGPT chat. ChatGPT gives me a code skeleton.
Or I can even ask for a skeleton scraping LinkedIn using Seleniumand ChatGPT gives me the following output.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
# Initialize the web driver
driver = webdriver.Firefox()
# Navigate to LinkedIn
driver.get("https://www.linkedin.com/")
# Find the email and password input fields
email = driver.find_element_by_id("username")
password = driver.find_element_by_id("password")
# Enter your credentials
email.send_keys("YOUR_EMAIL")
password.send_keys("YOUR_PASSWORD")
# Click the login button
driver.find_element_by_xpath("//button[@type="submit"]").click()
# Wait for the page to load
time.sleep(5)
# Navigate to the profile of the desired user
driver.get("https://www.linkedin.com/in/USER_PROFILE_NAME")
# Extract the information you want from the page
name = driver.find_element_by_xpath("//span[@class="inline t-24 t-black t-normal break-words"]").text
location = driver.find_element_by_xpath("//span[@class="t-16 t-black t-normal inline-block"]").text
print(name)
print(location)
# close the browser
driver.quit()
Easy, right? Try challenging ChatGPT with any project you can imagine.
Making decisions about how to implement something can be difficult, especially when there are multiple options to choose from. My go-to method is to create a basic proof of concept for each approach and then compare them. But, with the help of ChatGPT, this process is now much easier.
Now I can directly ask you for your expert opinion on which option or library is best for my code development. This saves me time and effort in the decision-making process and ensures that I am using the best tools for the job.
Let’s say I want to work with geospatial data but I’m not sure if I should use Geopandas
or a Plotly
. I can ask ChatGPT to compare for me, with a type included 😉 and it immediately answers the main differences between both libraries.
Screenshot ChatGPT chat. ChatGPT explains me the differences between geopandas and plotly.
If now I want to scrape a website, I may ask what is the best library to do it. ChatGPT is responsive with the most popular web scraping libraries in Python.
Screenshot ChatGPT chat. ChatGPT explains the most popular scraping website
You can even ask what is the best option for the website you want to scrape, although ChatGPT will most likely warn you that it will be against that website’s content policy, so be careful.
What is the best option to scrape a social network?
Screenshot ChatGPT chat. ChatGPT explains the best option to scrape a social network.
We have all been there, struggling to understand a codebase that wasn’t created by us. Navigate through complex and poorly organized code, also known as spaghetti code – it can be a frustrating and time consuming task.
But, with ChatGPT, understanding a new code base is now much easier. Now I can just ask him to explain the functionality of the code and understand it in no time. Stop wasting valuable time and effort trying to crack poorly written code.
Let’s say I’m trying to scrape Linkedin and I find a random code on the internet that is supposed to scroll down the Linkedin job postings website.
What does the following code do? [insert code here]
#We find how many jobs are offered.
jobs_num = driver.find_element(By.CSS_SELECTOR,"h1>span").get_attribute("innerText")
if len(jobs_num.split(',')) > 1:
jobs_num = int(jobs_num.split(',')[0])*1000
else:
jobs_num = int(jobs_num)
jobs_num = int(jobs_num)
#Here I choose manually a number of jobs, so it wont take that long:
jobs_num = 1000;
#We create a while loop to browse all jobs.
i = 2
while i <= int(jobs_num/2)+1:
#We keep scrollind down to the end of the view.
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
i = i + 1
print("Current at: ", i, "Percentage at: ", ((i+1)/(int(jobs_num/2)+1))*100, "%",end="\r")
try:
#We try to click on the load more results buttons in case it is already displayed.
infinite_scroller_button = driver.find_element(By.XPATH, ".//button[@aria-label="Load more results"]")
infinite_scroller_button.click()
time.sleep(0.1)
except:
#If there is no button, there will be an error, so we keep scrolling down.
time.sleep(0.1)
pass
And ChatGPT immediately responds with a very detailed explanation of the above code. You can even ask for more details in a certain part of the code: just play around with ChatGPT and you will discover all the wonders it can do.
Screenshot ChatGPT chat. ChatGPT explains the code which I didn’t understand.
ChatGPT can also help us improve the quality and maintainability of our own code. By asking you to add line-by-line comments, we can ensure our code is properly documented before shipping. This eliminates the need for uncommented code and makes it easier for others to understand and work with our code.
ChatGPT can significantly improve readability, maintainability, and collaboration with others.
Let’s say the above code didn’t have any comments. We can simply ask ChaGPT to add comments directly.
Add comments to the following code [insert code here]
# Find the number of jobs offered on the website
jobs_num = driver.find_element(By.CSS_SELECTOR,"h1>span").get_attribute("innerText")
# Check if the number of jobs contains a ',' and if so, convert it to number * 1000
if len(jobs_num.split(',')) > 1:
jobs_num = int(jobs_num.split(',')[0])*1000
else:
jobs_num = int(jobs_num)
# Convert jobs_num to an integer
jobs_num = int(jobs_num)
# Set the number of jobs to scrape to 1000
jobs_num = 1000;
# Initialize a counter variable to scroll through the jobs
i = 2
# Start a while loop to scroll through the jobs
while i <= int(jobs_num/2)+1:
# Scroll to the bottom of the page
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
# Increment the counter variable
i = i + 1
# Print the current number of jobs scrolled through and the percentage of completion
print("Current at: ", i, "Percentage at: ", ((i+1)/(int(jobs_num/2)+1))*100, "%",end="\r")
try:
# Try to locate the "Load more results" button and click on it
infinite_scroller_button = driver.find_element(By.XPATH, ".//button[@aria-label="Load more results"]")
infinite_scroller_button.click()
# Sleep for 0.1 seconds
time.sleep(0.1)
except:
# If the button is not present, sleep for 0.1 seconds and continue scrolling
time.sleep(0.1)
pass
Impressive right? No more uncommented code! 😀
ChatGPT is not only a valuable tool for understanding unknown code, but it can also help us ensure that our own code follows industry standards and conventions. By asking you to fix our code to comply with the Pep-8 convention, or even create a custom convention for our coding style, we can avoid the need for costly and time-consuming refactoring when merging code from different repositories or teams.
This helps streamline the collaboration process and make it more efficient. Overall, ChatGPT is a versatile tool that can improve the quality and maintainability of our code base.
If we ask ChatGPT to write the above code using the Pep-8 standard, it will directly give us the refactored code.
Can you rewrite the following code using the Pep8 standard? [Insert code here]
Screenshot ChatGPT chat. ChatGPT giving our code following the Pep8 standard.
I hope that after this article you realize that ChatGPT can help us be more productive and create higher quality results. I know it can be easy to fall into the trap of thinking that AI will eventually take over our jobs, but the right kind of AI can be a powerful asset that can be used on our behalf.
However, it is important to remember that critical thinking is still key when working with AIjust like when working with our human colleagues.
So before you rush to implement AI-generated responses, be sure to take the time to review and evaluate them first. Trust me, it’s worth it in the end!
Let me know if ChatGPT surprises you with other good features. I read you in the comments! 😀
Joseph Ferrer is an analytical engineer from Barcelona. He graduated in physical engineering and currently works in the field of Data Science applied to human mobility. He is a part-time content creator focused on data science and technology. You can contact him at LinkedIn, Twitter either Half.
Original. Reposted with permission.