Re: HOW in the HECK can we import comma quote delimted ASCII !!!????
Posted in 1995
Well, here's my stab at it... Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip /* * asc2infmx.c * Convert comma-delimited (w/ optional quotes) records to Informix "unload" * format. */ #include <stdio.h> main(argc, argv) int argc; char *argv[]; { void perror(); if (!*++argv) process(); else do { if (!freopen(*argv, "r", stdin)) { perror(*argv); continue; } process(); } while (*++argv); return(0); } process() { register int c, in_a_quote = 0; while ((c = getchar()) != EOF) switch(c) { case ',': (void)putchar((in_a_quote) ? c : '|'); break; case '"': in_a_quote = !in_a_quote; break; case '\\n': (void)putchar('|'); default: (void)putchar(c); break; } } Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip DAS -- Dave Snyder @ Bell Atlantic - Philadelphia, PA WEB: http://www.ece.vill.edu/~dave/index.html EMAIL: (w) ddx85qr@boots.bell-atl.com (h) dave@das13.snide.com