Report this

What is the reason for this report?

How to Arrange string data if both data have different spellings

Posted on February 18, 2022

I’ve been given a task to sort 1400 city names which has wrong spellings. with another data which has the right spellings. I want the result to be shown as the right and wrong data alligned together next to each other.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

It would really depend on the data, but what you could do is try and use the following Bash script:

#!/bin/bash

# A file containing the city list with the wrong names:
wrong_names=wrong.txt

# A file containing the city list with the right names:
right_names=right.txt

# Sort the files:
wrong_names_sorted=$(cat ${wrong_names} | sort > wrong_names_sorted.txt)
right_names_sorted=$(cat ${right_names} | sort > right_names_sorted.txt)

# Compare the two sorted files side by side:

sdiff ${wrong_names_sorted} ${right_names_sorted}

Hope that this helps!

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.