Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi everyone,
I am new to this forum and would appreciate your help.
I am trying to extract rows from a pipe-delimited flat file that is too large to load into excel.
One of my search criteria is to compare on the same line, two address fields. If different, then output the entire line into a different text file. Then I would load this into excel and manipulate accordingly.
A second search criteria is more complicated. Data (property address) can be on multiple lines (one after another). For each unique property address, if there is more than one row that has the same value for a date field, output all lines with same address and same date field to a different flat file.
Any help would be appreciated. I used to program in Perl in Unix, but it has been over 15 years. Now, I would like to do this in Windows XP but don't know how to maneuver anymore. I would be open to other Windows XP scripting language if it would make life simpler such as batch.
Thank you in advance for all your help.
Duane.

if you know Perl on Unix, then you can do the same with Windows. Go download Perl for windows from Activestate and you can start programming your task.

Hello ghostdog,
Thank you for your reply. Unfortunately, I have been out of programming for 15 years now and am looking for help on how to do this in perl or in any other language.
If you have any tips on simple programming to accomplish above, I would certainly appreciate it.
Thanks again for your response,
Duane.

>>I have been out of programming for 15 years now and am looking for help on how to do this in perl or in any other language.
firstly , remember 15 yrs ago, how did you learn Perl. reading a Perl book? it will be the same. Please type perldoc perl and read the documentation.
secondly, i (or anybody ) work well with examples , especially if you describe with example of sample input files, sample output you expect. after reading your whole first post, i still don't understand what you are trying to do.
lastly, on a personal note, while Perl can be used to do stuff, i prefer Python due to its clear syntax and powerful string manipulation capabilities (among other things, like modules). anyway, i am most willing to help , but first put your problem across more clearly with examples.

If you post enough lines and explain the field layout, I'll work on it.
=====================================
If at first you don't succeed, you're about average.M2


uh... I don't see any pipes there.
=====================================
If at first you don't succeed, you're about average.M2

yes, you are correct. The pipe delimited file to which I was referring was another file that I was attempting to manipulate at the time. Therefore, I should have stated a CSV file vs. pipe delimited.
Apologies for that,
Duane.

if you have Python on Windows
import os,sys,csv filename = sys.argv[1] outputfile = sys.argv[2] pos1=int(sys.argv[3]) pos2=int(sys.argv[4]) lines={} count={} reader = csv.reader(open(filename)) writer = csv.writer(open(outputfile,"w"),delimiter=",") for n,row in enumerate(reader): row[pos2] = row[pos2].strip() row[pos1] = row[pos1].strip() count.setdefault(row[pos2],0) lines.setdefault(row[pos2] , []) count[row[pos2]] = count[row[pos2]] + 1 lines[row[pos2]].append(row) for i,j in count.iteritems(): if j > 1: for o in lines[i]: writer.writerow(o)usage:
c:\test> python test.py <input> <outfile> <pos1> <pos2>here's an executableyou can run in batch if you don't want to download Python
C:\test>test.exe file.txt outfile.txt 7 16 C:\test>more outfile.txt 1608,"ENGLEHARDT,EDWIN SHERIFF",COUNTY OF PASSAIC,PASSAIC NJ 00000,BANKERS TRUST,6700 S POINT TH 6TH ST,A0058,2,,2,1400,15500,16900,2/15/1995,1/20/1995,V138,270,100,12,0,9,3348495,0 1608,BANKERS TRUST CO OF CA,11000 BROKEN LAND PKWY,COLUMBIA MD 00000,PRP ASSOC,34 N SIXTH ST,P 6TH ST,A0058,2,,2,1400,15500,16900,11/22/1995,1/20/1995,L142,90,35900,26,0,9,3711500,0 1608,"RIVERA,EDDIE & ENES",165 20TH AVE,PATERSN NJ 00000,"RIVERA,ENES",157 TEMPLE ST,PATERSON 58,1,,2,1400,15000,16400,9/6/1989,5/21/2002,B125,459,0,26,0,8,1663663,0 1608,TCIF RE02 LLC,3815 S WEST TEMPLE,SALT LAKE CITY UT 00000,BARNA NORMAN,12 RAVINE CT,CLIFTO 0058,1,,2,1400,15000,16400,6/6/2002,5/21/2002,427,174,100000,,0,,6657954,0 1608,TCIF LLC,3815 SOUTH W TEMPLE,SALT LAKE CITY UT 00000,TCIF RE02 LLC,3815 S OUTH W TEMPLE,S TEMPLE ST,A0058,1,,2,1400,15000,16400,6/6/2002,5/21/2002,427,167,0,25,0,,6657953,0

hello ghostdog,
thank you so much for your help! i will test this out tomorrow as it is getting late. but i did want to let you know how much i appreciate it :)
thanks again,
duane.

![]() |
String Compair Problems
|
INI Files in C. Read and ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |