Article View: alt.lang.basic
Article #70Re: Help Needed: How to write "comma and quote" delimited files?
From: Ofer Inbar
Date: Tue, 21 Jul 1992 19:35
Date: Tue, 21 Jul 1992 19:35
53 lines
2169 bytes
2169 bytes
jakerjor@magnus.acs.ohio-state.edu (Jan O Akerjordet) writes:
>I am trying to make a program that will convert data in a certain
>format to a "comma and quote" delimited file. The reason is so
>that it can be imported into a database. The program works fine
>and the data is in the format shown below:
>
>Example:
>
>"Data about widget X",
>"Date of production",
>"kasdgf",
>"jsgfg jagja asdfaj"
>
>"jasdff jasdfjasdf",
>"jdsff jsdf",
>"kgf mmcv",
>"kfdgg lflfl"
>
>and so on .....
>
>However, I discovered that the database needed it to be in this format:
>
>"kasdfsdf","jkasdff","ksdfksdfk kasdf","ksdfdsfkfk","lksdfg"
>"ksdf","gasdf","kldfadfs","kasdfa","lasdfasd"
I think perl is a better tool for this job, but here it is in QuickBASIC:
OPEN "oldfile.dat" FOR INPUT AS #1 'one field per line
OPEN "newfile.dat" FOR OUTPUT AS #2 'one record per line (new)
DO
LINE INPUT #1, Field$
IF LTRIM$(Field$) = "" THEN
PRINT #2, Record$
Record$ = ""
ELSE
Record$ = Record$ + Field$
END IF
LOOP UNTIL EOF(1)
IF Record$ <> "" THEN PRINT #2, Record$
CLOSE
END
I just wrote this up off the top of my head, no testing, so it
probably needs to be debugged. But it shows you the general idea.
Seems pretty simple, unless I missed some important detail.
-- Cos (Ofer Inbar) -- cos@chaos.cs.brandeis.edu
-- WBRS (BRiS) -- WBRS@binah.cc.brandeis.edu WBRS@brandeis.bitnet
FidoNet: Ofer Inbar on 1:101/310 -- Ofer.Inbar@f310.n101.z1.fidonet.org
The Boston Computer Society IBM PC User Group TBBS, (617) 332-5584
Technical Details
Message-ID:
<cos.711747323@chaos.cs.brandeis.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!jvnc.net!yale.edu!qt.cs.utexas.edu!news.Brown.EDU!noc.near.net!news.cs.brandeis.edu!chaos.cs.brandeis.edu!cosReferences:
<1992Jul18.014514.14693@magnus.acs.ohio-state.edu>Show Full Headers
Complete Article Headers
Newsgroups: alt.lang.basic Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!jvnc.net!yale.edu!qt.cs.utexas.edu!news.Brown.EDU!noc.near.net!news.cs.brandeis.edu!chaos.cs.brandeis.edu!cos From: cos@chaos.cs.brandeis.edu (Ofer Inbar) Subject: Re: Help Needed: How to write "comma and quote" delimited files? Message-ID: <cos.711747323@chaos.cs.brandeis.edu> Sender: news@news.cs.brandeis.edu (USENET News System) Organization: Brandeis University References: <1992Jul18.014514.14693@magnus.acs.ohio-state.edu> Date: Tue, 21 Jul 1992 19:35:23 GMT Lines: 53