DEV Community

Judy
Judy

Posted on

2 1 1 1 1

Perform Distinct on Ordered Numbers in a Text File #eg61

Problem description & analysis

Below is data in text file txt.txt:

Image description
Each row in the text file contains a number. There are duplicates and rows are already sorted. We are trying to trim the file to remove the duplicates and generate a new ordered file, as shown below:

Image description
Solution

Write the following script p1.dfx in esProc:

Image description
Explanation:

A1   Import the txt data; @i option enables returning a sequence when the result set has only one column.

A2  Perform distinct on A1’s ordered sequence and export result to result.txt.

Explanation:

A1   Import the txt data; @i option enables returning a sequence when the result set has only one column.

A2  Perform distinct on A1’s ordered sequence and export result to result.txt.

SPL open source address

Download

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay