Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7029373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:31:50+00:00 2026-05-28T00:31:50+00:00

I have a CSV file with two columns: cat @ c a t dog

  • 0

I have a CSV file with two columns:

cat @ c a t
dog @ d o g
bat @ b a t

To simplify communication, I’ve used English letters for this example, but I’m dealing with CJK in UTF-8.

I would like to delete any character appearing in the second column, which appears on fewer than 20 lines within the first column (characters could be anything from numbers, letters, to Chinese characters, and punctuation, but not spaces).

For e.g., if “o” appears on 15 lines in the first column, all appearances of “o” are deleted from the second column. If “a” appears on 35 lines in the first column, no change is made.

  • The first column must not be changed.
  • I don’t need to count multiple appearances of a letter on a single line. For e.g. “robot” has 2 o’s, but this detail is not important, only that “robot” has an “o”, so that is counted as one line.

How can I delete the characters that appear less than 20 times?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:31:51+00:00Added an answer on May 28, 2026 at 12:31 am

    Here is a script using awk. Change the var num to be your frequency cutoff point. I’ve set it to 1 to show how it works against a small sample file. Note how f is still deleted even though it shows up three times on a single line. Also, passing the same input file twice is not a typo.

    awk -v num=1 '
    BEGIN { OFS=FS="@" }
    FNR==NR{
        split($1,a,"")
        for (x in a)
            if(a[x] != " " && !c[a[x]]++)
                l[a[x]]++
        delete c
        next
    }
    !flag++{
        for (x in l)
            if (l[x] <= num)
                cclass = cclass x
    }
    {
         gsub("["cclass"]", " " , $2)
    }1' ./infile.csv ./infile.csv
    

    Sample Input

    $ cat ./infile
    fff @ f f f
    cat @ c a t
    dog @ d o g
    bat @ b a t
    

    Output

    $ ./delchar.sh
    fff @
    cat @  a t
    dog @
    bat @  a t
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV file with two columns: city and zipcode. I want to
I have a csv file which has two columns, a numeric ID ( IDVAR
I have two csv file. First File has date offerid clicks orders Second File
I have a csv file (5 columns, with | as delimiter) and I want
I have 1000 CSV files from dfr.jstor.org with two columns, KEYWORDS and WEIGHT. The
I am trying to create a CSV file. I have done this. I have
I have a CSV file with lines like this: AAA,A-name,num1,num2,num3 BBB,B-name,num1,num2,num3 CCC.DDD,C-name,num1,num2,num3 EEE.FFF.GGGG,E-name,num1,num2,num3 HHH.H-name,num1,num2,num3
This is a part of a large csv file which I have: 66.35.223.128,66.35.223.143,1109647232,1109647247,AU,Australia 66.35.223.144,66.35.227.191,1109647248,1109648319,US,United
I have csv file with 14 columns and I want to sort it in
I have a CSV file with three columns (A,B,C). I can record a Macro

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.