The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
unix awk/sed program mnnarendra UNIX for Advanced & Expert Users 4 03-26-2008 07:00 AM
UNIX program? threewingedfury UNIX for Dummies Questions & Answers 1 02-05-2008 12:15 PM
How do i run a program while in Unix?.... Corrail UNIX for Dummies Questions & Answers 4 10-31-2005 11:51 AM
looking for a unix C program...help please richardspence2 UNIX for Advanced & Expert Users 3 03-15-2004 09:14 PM
running a c/c++ program in unix kray High Level Programming 2 07-12-2002 12:25 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-21-2005
Registered User
 

Join Date: Feb 2005
Posts: 3
Help with UNIX Program

I am trying to set up a file for someone and they have a program that was built for UNIX. I am guessing that it is running in some sort of emulator since they are on WinXP. It is a database and we are trying to get all of the addresses out of the database. I talked to the tech support for the software, and if I understood them correctly, this is all that can be done.

The data can be outputted to a file (.tmp I believe) and then the information can be saved out to something else. The problem is that it won't be delimited. It will just be one long string of text according to the tech support. Does anyone have any ideas on what I could do to get this in a usable format. The database is about 6000 names, so if you figure that by about 6 pieces of information per name, there is no way that we can go in and physically delimit it.

In case your wondering, the program was written in the early 80's. The new version will output to databbase files, but the upgrade is 100,000 and they aren't willing to do that.

Help.
Reply With Quote
Forum Sponsor
  #2  
Old 02-21-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Well how about a few clues here?? How are we supposed to know where the delimiters go? Post some sample data. And maybe you should tell us what you want to use as a delimiter.
Reply With Quote
  #3  
Old 02-21-2005
Registered User
 

Join Date: Feb 2005
Posts: 3
Well, I will know more tomorrow. I was basically asking if something like this is possible. If it is what has been explained to me, the data has a fixed number of characters for each field. It can be comma or tab delimited, but I would prefer tab. Once I actually get the file, I'll post some info.
Reply With Quote
  #4  
Old 02-25-2005
Registered User
 

Join Date: Feb 2005
Posts: 3
Ok. Here is a sample of the file I am working with. Turns out, it did format the text, it just isn't the format we need.

What I need is a spreadsheet with the name in one column, the address line in one column and the city, state, zip in another column.

I don't think this is a Unix problem to solve, but more of an excel issue. Maybe a macro to move the information? I also need it to clean out all the blank lines.

The sample is attached to this.
Attached Files
File Type: txt sampletext.txt (1,000 Bytes, 12 views)
Reply With Quote
  #5  
Old 02-25-2005
bhargav's Avatar
Registered User
 

Join Date: Sep 2004
Location: USA
Posts: 511
I guess Windows Excel may solve the problem.

But , using unix scripting also we can solve this.
Reply With Quote
  #6  
Old 02-25-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Quote:
Originally Posted by brand1m
Ok. Here is a sample of the file I am working with. Turns out, it did format the text, it just isn't the format we need.

What I need is a spreadsheet with the name in one column, the address line in one column and the city, state, zip in another column.

I don't think this is a Unix problem to solve, but more of an excel issue. Maybe a macro to move the information? I also need it to clean out all the blank lines.

The sample is attached to this.
here's something to start with given your sample file.
Assumptions:
  1. there're 2 columns in your original file
  2. maximum width of the first column is 34 character - this is adjustable
  3. the output fields are separated by "|" - configurable

attached is a the output based on your sample input.

nawk -f brand.awk samplefile.txt

brand.awk:
Code:
BEGIN {
  OFS="|"
  CLMN=2
  WDTH=34
}

#------------------------------------------------------------------------
#
function trim(str)
{
   sub("^[ \t]*", "", str);
   sub("[ \t]*$", "", str);
   return str;
}

#------------------------------------------------------------------------
#
pivot == 3 {
  for(i=1; i <= CLMN; i++)
    for(j=1; j <= pivot; j++) {
      split(arr[j], tmpA, SUBSEP)
      printf("%s%s", tmpA[i], (j < pivot) ? OFS : "\n");
    }
  pivot=0
}

!NF { pivot=0; next}

{
   pivot++
   arr[pivot] = trim(substr($0, 1, WDTH-1)) SUBSEP trim(substr($0, WDTH))
}
Attached Files
File Type: txt sampleoutput.txt (424 Bytes, 6 views)
Reply With Quote
  #7  
Old 02-28-2005
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
watch out for typos

pivot == 3 should read pivot = 3
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0