Featured Post

8 Ways to Optimize AWS Glue Jobs in a Nutshell

Image
  Improving the performance of AWS Glue jobs involves several strategies that target different aspects of the ETL (Extract, Transform, Load) process. Here are some key practices. 1. Optimize Job Scripts Partitioning : Ensure your data is properly partitioned. Partitioning divides your data into manageable chunks, allowing parallel processing and reducing the amount of data scanned. Filtering : Apply pushdown predicates to filter data early in the ETL process, reducing the amount of data processed downstream. Compression : Use compressed file formats (e.g., Parquet, ORC) for your data sources and sinks. These formats not only reduce storage costs but also improve I/O performance. Optimize Transformations : Minimize the number of transformations and actions in your script. Combine transformations where possible and use DataFrame APIs which are optimized for performance. 2. Use Appropriate Data Formats Parquet and ORC : These columnar formats are efficient for storage and querying, signif

Python Split String: Techniques and Best Practices

Here is an example for splitting a string in Python. The functions you need are strip and split to split string, or text. 

python split string


Here's the string taken for split

My task is I want to split address string. Historically, the address is lengthy. It contains the door number, floor number, street number, and street name.

Rama Krishna 20/3 ABC street EFG Nagar US 234567

How to Split a string

The python split string works in two steps. The first step is to use strip function, which removes both leading and trailing spaces. Next, use the the split function, which splits the input string, or text into a list.

Python program

user_address = input("Enter an address")

if user_address.strip(): #check that string is not empty (after removing leading
#and trailing spaces)
    print("Your address is " + user_address)
split_address = user_address.split()
print(split_address)

Output

Interactively, it asks the user to enter the address. After the code runs, the address splits into separate strings in a list.

Enter an address
Rama Krishna 20/3 ABC street EFG Nagar US 234567

Your address is Rama Krishna 20/3 ABC street EFG Nagar US 234567
['Rama', 'Krishna', '20/3', 'ABC', 'street', 'EFG', 'Nagar', 'US', '234567']

** Process exited - Return Code: 0 **
Press Enter to exit terminal

Comments

Popular posts from this blog

How to Fix datetime Import Error in Python Quickly

How to Check Kafka Available Brokers

SQL Query: 3 Methods for Calculating Cumulative SUM