Text import

From: Vijay Deval <deval(at)giaspn01(dot)vsnl(dot)net(dot)in>
To: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Text import
Date: 2001-08-30 03:28:27
Message-ID: 3B8DB2DB.2C0EE13D@giaspn01.vsnl.net.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Dear Pete

I have posted one script to insert field saperator into fixed length
fields text file. I feel the following version is better than the
previous.
Vijay

-------------------------------------------------------------------

#include <stdio.h>

#define FNM 5 /* number of fields */
#define F1 4 /* length of the first field */
#define FS "|" /* field saperator */
main()
{
int c,i,len,count;
int flen[FNM-2];
flen[0]=45; /*length of second field */
flen[1]=40; /* length of third field */
flen[2]=40; /* length of last field not reqd */

count=0;
i=0;
len=F1;
c=getchar();
while (c != EOF){

putchar(c);
count=count+1;
c=getchar();


if (count==len){
printf("%s",FS);
len=len+flen[i];
i=i+1;
}
if (c=='\n'){
count=0;
i=0;
len=F1;
putchar(c);
c=getchar();
}
}
}
-----------------------------------------------------------------------------

Attachment Content-Type Size
fields.c text/plain 678 bytes

Browse pgsql-novice by date

  From Date Subject
Next Message Jason Tan 2001-08-30 09:18:10 pl/pgsql recursion/arrays (fwd)
Previous Message Marc G. Fournier 2001-08-29 15:00:38 List archives moved and cleaned up ...