Untitled

 avatar
unknown
plain_text
a year ago
673 B
6
Indexable
import pandas as pd
from google.colab import files

def extract_suffix(part_number):
    # Split the part number by '-' and return the last part
    return part_number.split('-')[-1]

# Upload the CSV file
uploaded = files.upload()

# Get the filename of the uploaded file
filename = next(iter(uploaded))

# Read the CSV file
df = pd.read_csv(filename)

# Extract suffixes
df['Suffix'] = df['PN'].apply(extract_suffix)

# Display the first few rows of the result
print(df.head())

# Save the result to a new CSV file
result_filename = 'result_' + filename
df.to_csv(result_filename, index=False)
files.download(result_filename)

print(f"Results saved to {result_filename}")
Editor is loading...
Leave a Comment