Tech Support > Operating Systems > MS-DOS > opening up a file and processing it line-by-line reading comma delimited values into variables
opening up a file and processing it line-by-line reading comma delimited values into variables
Posted by DaveC on June 3rd, 2004


I need help with the following;
I have exported data from a database into a text file, which is 2
fields in the format "area1 area2"
There are a number of rows. What I need to do is put those values into
another text file with the end result looking like this:
insert into ProgramSubProgramLists values('area1', 'area2')
where "insert into programsubprogramlists valus('', '') already exists
and I am just appending it.
Any help would be great!

Posted by Ted Davis on June 3rd, 2004


On 3 Jun 2004 11:26:06 -0700, daveclarke77@yahoo.com (DaveC) wrote:

This is not something DOS does - you need a utility in some high level
language, though it is sorta possible in the NT series operating
systems. Personally, I would use a gawk script, but there isn't
enough information to write a sensible one.

The subject implies that the source file is comma delimited, but you
show it as space or tab (unclear) delimited - the target file can't be
considered as comma delimited either: there is a comma present, but
the line really isn't comma delimited.

It appears that you want to replace
","
in one file with the single quoted two unclear delimited fields in
another on a line by line basis, but with no indication of what to do
if they don't have matching numbers of lines. The rest of the target
file is also unknown - from what is known, it would be easier to
generate the target file by writing the entire line instead of
modifying an existing file. There are also questions about what
operating system this is for.



T.E.D. (tdavis@gearbox.maem.umr.edu)
SPAM filter: Messages to this address *must* contain "T.E.D."
somewhere in the body or they will be automatically rejected.

Posted by Matthias Tacke on June 3rd, 2004


DaveC wrote:
Hello Dave.

(tab and or spaces) ?

What os do you use?

In case of w2k/xp (where the proper ng is news:alt.msdos.batch.nt )
this could work:

@echo off
for /F "tokens=1,*" %%A in ('type Source.txt') do (

HTH
--
Greetings
Matthias

Posted by Dr John Stockton on June 4th, 2004


JRS: In article <aceee993.0406031026.666df704@posting.google.com>, seen
in news:alt.msdos.batch, DaveC <daveclarke77@yahoo.com> posted at Thu, 3
Jun 2004 11:26:06 :
COLS < file.txt 'insert * 'into * 'ProgramSubProgramLists * 'values('
F1 '', * '' F2 '') > another.txt

all on one line. Get COLS via sig line 3, for DOS * Windows DOS boxes.
If there are commas in the input, change them to spaces with SUBS.

MiniTrue should provide another general solution, via sig line 4..

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; Win98. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.

Posted by Mabden on June 23rd, 2004


"DaveC" <daveclarke77@yahoo.com> wrote in message
news:aceee993.0406031026.666df704@posting.google.c om...
This is the sort of thing Perl is good for.
http://www.perl.com/download.csp

--
Mabden




Similar Posts