Sponsored Content
Full Discussion: Use awk to pick out zip code
Top Forums Shell Programming and Scripting Use awk to pick out zip code Post 302352575 by grossgermany on Saturday 12th of September 2009 02:43:19 AM
Old 09-12-2009
Use awk to pick out zip code

Hi,

Suppose I have a csv file, each line look like this:
ABC Company, 1999, March, caucasian owned, 123 BroadWay NY 92939-2222

How do I create two new columns at the end, one for state, one for zip.

So that the line is
ABC Company, 1999, March, caucasian owned, 123 BroadWay NY 92939-2222,NY,92939-2222


To help you with the code, I've created a list of all possible State Abbreviations.
[AL, AK, AZ, AR, CA, CO, CT, DE, DC, FL, GA, ID, IL, IN, IA, KS, LA, MD, MA, MI, MN, MS, MO, MT, NE, NV, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VA, WA, WV, WI, WY]
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pick up the return code for every iteration and display the result only once in loop.

Hi All, I amlearning UNIX scripting. I have a small query. I would be thankful if any one helps me out. I have a below piece of code which delets the files. If file dosent have the permissions to delete a particular file I have used 2>>operator to track the error code. But my objective is... (1 Reply)
Discussion started by: manas6
1 Replies

2. Shell Programming and Scripting

zip code filter problem using AWK need help

Hello all; I have a large file (csv file) with addresses. I am trying to filter out specific entries based on zip code from a particular column of data. However my awk statement can not account for zipcode that begins with a certain pattern. It finds the pattern anywhere within the zipcode. ... (3 Replies)
Discussion started by: nelsonsierra
3 Replies

3. Shell Programming and Scripting

Manipulating Pick multi dimensional data with awk.

Hi. I am reasonably new to awk, but have done quite a lot of unix scripting in the past. I have resolved the issues below with unix scripting but it runs like a dog. Moved to awk for speed and functionality but running up a big learning curve in a hurry, so hope there is some help here. I... (6 Replies)
Discussion started by: mike.strategis
6 Replies

4. UNIX Desktop Questions & Answers

awk to pick out more than one line

This really is a dummy question but I'm stuck and out of time... I have a large file and out of it I only want to pick out lines starting with either "Pressure" or "N". I still need these lines to be in their original order. example of text Pressure 3 N 2 N 3 bla bla bla bla Pressure 4... (3 Replies)
Discussion started by: jenjen_mt
3 Replies

5. Shell Programming and Scripting

use awk pick value from lines as condition for grep

Hi Folks! I have a file like this 000000006 dist:0.0 FILE ./MintRoute/MultiHopWMEWMA.nc LINE:305:1 NODE_KIND:131 nVARs:4 NUM_NODE:66 TBID:733 TEID:758 000000000 dist:0.0 FILE ./Route/MultiHopLEPSM.nc LINE:266:1 NODE_KIND:131 nVARs:4 NUM_NODE:66 TBID:601 TEID:626 000000001 ... (2 Replies)
Discussion started by: jackoverflow
2 Replies

6. Shell Programming and Scripting

How to pick a group of data using awk/ksh

Hi gurus, I have data coming in as shown below. And in each case, I need to pick the data in the last group as shown below. Data Set 1: DC | 18161621 LA | 15730880 NY | 16143237 DC | 18161621 LA | 17316397 NY | 17915905 DC | 18161621 LA | 17993534 NY | 18161621 DC | 18161621... (11 Replies)
Discussion started by: calredd
11 Replies

7. Shell Programming and Scripting

Pick first "code" only [ grep/awk ]

All I have a requirement to search and pick the data as below. Explained with example. 38999|4812 Highway 52 North|Rockville|55901|0196 67541|2800 Dexter Road|Northville|38999|0196 This is pipe separate data. First column represents dealer id and 4th column represents the zip code where... (4 Replies)
Discussion started by: ak835
4 Replies

8. Shell Programming and Scripting

Code to pick all files from a directory and send it to a command

(4 Replies)
Discussion started by: rossi
4 Replies

9. Shell Programming and Scripting

awk - Pick last value from set of rows

Input data COL_1,COL_2,COL_3,COL_4,COL_5,COL_6,COL_7,COL_8,COL_9,COL_10,COL_11,COL_12,COL_13 C,ABC,ABCD,3,ZZ,WLOA,2015-12-01,2016-12-01,975.73,ZZZ,P,111111.00,Y1 **GROUP1** C,ABC,ABCD,3,ZZ,WLOA,2015-12-01,2016-12-01,975.73,ZZZ,P,222222.00,Y1 **GROUP1**... (2 Replies)
Discussion started by: Ads89
2 Replies
ZIP_SET_FILE_COMMENT(3) 				     Library Functions Manual					   ZIP_SET_FILE_COMMENT(3)

NAME
zip_set_file_comment - set comment for file in zip LIBRARY
libzip (-lzip) SYNOPSIS
#include <zip.h> int zip_set_file_comment(struct zip *archive, zip_uint64_t index); "const char *comment" "int len" DESCRIPTION
The zip_set_file_comment function sets the comment for the file at position index in the zip archive to comment of length len. If comment is NULL and len is 0, the file comment will be removed. RETURN VALUES
Upon successful completion 0 is returned. Otherwise, -1 is returned and the error information in archive is set to indicate the error. ERRORS
zip_set_file_comment fails if: [ZIP_ER_INVAL] index is not a valid file index in archive, or len is less than 0 or longer than the maximum comment length in a zip file (65535). [ZIP_ER_MEMORY] Required memory could not be allocated. SEE ALSO
libzip(3), zip_get_archive_comment(3), zip_get_file_comment(3), zip_set_archive_comment(3) AUTHORS
Dieter Baron <dillo@giga.or.at> and Thomas Klausner <tk@giga.or.at> NiH March 10, 2009 ZIP_SET_FILE_COMMENT(3)
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy