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 8423367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:42:19+00:00 2026-06-10T03:42:19+00:00

I have about 10-20K records and only need certain cities. I would like to

  • 0

I have about 10-20K records and only need certain cities. I would like to make this work in perl but i can’t seem to find an example of just what i need. searchme.csv and list.csv if city is found delete record/row. I was sorting and splitting the screen but now there is just way to many to hand pick out. Please any help would be much appreciated. Im only a nueb.

  1. searchme.csv contains rows with ‘name,address,city,state,zip,phone’ with header.
  2. list.csv contains 1 row with header ‘city’ and 50+ rows of the cities that I want to keep.
  3. So for each row in searchme.csv get the ‘city’ into a $variable and loop thru the list.csv if match found write the full row from searchme.csv to new file new.csv. the more i play with this i got it to loop over the searchme.csv, i think i need to load the cities.csv into and array and loop thru the array within the while loop. and if found print to new.csv.
  • 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-06-10T03:42:21+00:00Added an answer on June 10, 2026 at 3:42 am

    I couldn’t quite tell from your last comment whether you’re still working on this, or not. In any case, here’s a solution to consider.

    use strict;
    use warnings FATAL => 'all';
    use autodie qw(:all);
    
    # slurp files into arrays
    open my $RECORDSFILE, '<', 'searchme.csv';
    my @records = <$RECORDSFILE>;
    close $RECORDSFILE;
    
    open my $LISTFILE, '<', 'list.csv';
    my @citychecklist = <$LISTFILE>;
    close $LISTFILE;
    
    open my $NEWFILE, '>>', 'new.csv';
    
    my $cityidx = 2;
    my $item;
    my $record;
    
    # loop through each record and extract the city string
    foreach $record (@records) {
        my @data = split qr/,/, $record;
        my $city = $data[$cityidx];
        # skip the header
        next if $city eq 'city';
    
        # compare the city string with each city in our other list
        foreach $item (@citychecklist) {
            chomp $item;
            # if we find a match write out the record to another file
            if ($city eq $item) {
                print {$NEWFILE} $record;
            }
        }
    }
    
    close $NEWFILE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to make a page that would show about 20k lines and a
I have about 20,000 records (coming from an SQLite db) that I need to
i have about 8mb of sql code i need to run. it looks like
i have about 8mb of sql code i need to run. it looks like
I have a list of about 20k addresses in the US, and I would
I have about 360 lines of data which I need to make into 360
I have about 1 million records in my contact table in the DB, now
I have about 1500 images within a folder named 3410001ne => 3809962sw. I need
I have about 30 clickable divs on my page so I figured I would
I have about 100 elements in like and am trying to create an animation

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.