Hi Guys and Girls,
I'm trying to read from a file
The file contains call numbers, a variable amount.
The call numbers come after an identifier NOTF
I then want to put all the data after NOTF into a file, but call the file
the name of the unique call number.
so:
while (file not empty)
read (input file) // line by line
if (input file) = NOFT
create file (name of preceding call number)
put (data after NOTF)
until (next NOTF)
}
}
}
Sorry for the VERY bad psuedo code.
Regards,
Darren 4 4079
On Fri, 24 Oct 2003 10:10:03 +0100, Darren Stribling <da**************@hotmail.com> wrote:
Hi Guys and Girls,
I'm trying to read from a file
The file contains call numbers, a variable amount.
The call numbers come after an identifier NOTF
I then want to put all the data after NOTF into a file, but call the file the name of the unique call number.
so:
while (file not empty) read (input file) // line by line if (input file) = NOFT create file (name of preceding call number) put (data after NOTF) until (next NOTF) } } }
Sorry for the VERY bad psuedo code.
Regards,
Darren
Pseudo-code is just an outline, right? And where it all starts....
assuming the line looks like this, more-or-less:
NOTF 12334455 xxxxx xxxxx xxxxxxx xxxxxx xxxxx xxxxx
#!/bin/sh
if [ -s file ] ; then
while read line ; do
name=`echo $line | sed -n 's/\(^NOTF *\)\([0-9][0-9]*\)\( *.*\)/\2/p'`
info=`echo $line | sed -n 's/\(^NOTF *\)\([0-9][0-9]*\)\( *.*\)/\3p'`
echo "$info" > /dir/dir/$name
done < file
fi
exit 0
:-) Sorry. Couldn't resist.
C is making me feel dumb at present, and this cheered me up. Now where did
that banana go?
--
Alan C
Post validation at http://tinyurl.com/rv0y
thanks so much for that alan. i was looking at SED last night - but ended up
eating too much pizza instead!
i would like to run this on windows - i guess i could use a port of sed
instead?
"Alan Connor" <zz****@xxx.yyy> wrote in message
news:%9*************@newsread4.news.pas.earthlink. net... On Fri, 24 Oct 2003 10:10:03 +0100, Darren Stribling
<da**************@hotmail.com> wrote:
Hi Guys and Girls,
I'm trying to read from a file
The file contains call numbers, a variable amount.
The call numbers come after an identifier NOTF
I then want to put all the data after NOTF into a file, but call the
file the name of the unique call number.
so:
while (file not empty) read (input file) // line by line if (input file) = NOFT create file (name of preceding call number) put (data after NOTF) until (next NOTF) } } }
Sorry for the VERY bad psuedo code.
Regards,
Darren
Pseudo-code is just an outline, right? And where it all starts.... assuming the line looks like this, more-or-less:
NOTF 12334455 xxxxx xxxxx xxxxxxx xxxxxx xxxxx xxxxx #!/bin/sh
if [ -s file ] ; then
while read line ; do
name=`echo $line | sed -n 's/\(^NOTF *\)\([0-9][0-9]*\)\( *.*\)/\2/p'` info=`echo $line | sed -n 's/\(^NOTF *\)\([0-9][0-9]*\)\( *.*\)/\3p'`
echo "$info" > /dir/dir/$name
done < file
fi
exit 0
:-) Sorry. Couldn't resist.
C is making me feel dumb at present, and this cheered me up. Now where did that banana go?
-- Alan C Post validation at http://tinyurl.com/rv0y
Darren Stribling wrote: thanks so much for that alan. i was looking at SED last night - but ended up eating too much pizza instead!
i would like to run this on windows - i guess i could use a port of sed instead?
"Alan Connor" <zz****@xxx.yyy> wrote in message news:%9*************@newsread4.news.pas.earthlink. net...
On Fri, 24 Oct 2003 10:10:03 +0100, Darren Stribling
<snip>The call numbers come after an identifier NOTF
Note for later: "after" => succeeding. I then want to put all the data after NOTF into a file, but call the file the name of the unique call number.
so:
while (file not empty) read (input file) // line by line if (input file) = NOFT create file (name of preceding call number)
"preceeding"? You described "succeeding" in your text above.
put (data after NOTF) until (next NOTF)
Note: implies there's a second NOTF on the same line to terminate the
input. OR do you mean to say that the data can actually span multiple
lines and you want to keep reading between NOTFs?
<snip>assuming the line looks like this, more-or-less:
NOTF 12334455 xxxxx xxxxx xxxxxxx xxxxxx xxxxx xxxxx
He didn't say that NOTF would be the first thing on the line and he said
there was a second NOTF to terminate the data.
<snip>name=`echo $line | sed -n 's/\(^NOTF *\)\([0-9][0-9]*\)\( *.*\)/\2/p'` info=`echo $line | sed -n 's/\(^NOTF *\)\([0-9][0-9]*\)\( *.*\)/\3p'`
These won't work if the input data is really:
abcd NOTF 1234 def ghi NOTF klm nop
and he wants "1234" for "name" and "def ghi" for "info" which his text
implies. Also, if he really wants to name the file based on the
PRECEEDING call number and/or the data can span multiple lines, that
requires a little different approach.
OP - if you want a C solution, attempt it and post the attempt here. If
you want a shell solution, try posting to comp.unix.shell and take a
look at www.cygwin.org for a UNIX-like environment for Windows.
Ed.
Darren Stribling wrote: thanks so much for that alan. i was looking at SED last night - but ended up eating too much pizza instead!
i would like to run this on windows - i guess i could use a port of sed instead?
Your chances of getting reasonable suggestions would be greatly
enhanced by refraining from top-posting. As it is the thread is a
completely illegible jumble.
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: firegun9 |
last post by:
Hello all,
After looking for the solution for a while in the group, I know this is
not possible in C++. So I just say my problme here.
The input file is:
dev1 1 1
dev2 0 0 0 6
There is a...
|
by: swarsa |
last post by:
Hi All,
I realize this is not a Palm OS development forum, however, even though
my question is about a Palm C program I'm writing, I believe the topics
are relevant here. This is because I...
|
by: collinm |
last post by:
hi
i expect to find 7 file on a folder... maybe less, maybe more...
i can surely put this number to 1... but i think doing some realloc
will be expensive...
after 7 files, i need to use...
|
by: Bill |
last post by:
By dynamic mapping, I meant that before the records are
transferred from one table to the other(source to target),
the xml file which will have the field names of the two
tables mapped, is to be...
|
by: Leo J. Hart IV |
last post by:
OK, here's another question for the experts:
I am building a multi-step (3 steps actually) form using a panel for
each step and hiding/displaying the appropriate panel/panels depending
on which...
|
by: serge |
last post by:
How can I run a single SP by asking multiple sales question either
by using the logical operator AND for all the questions; or using
the logical operator OR for all the questions. So it's always...
|
by: Sakcee |
last post by:
python provides a great way of dynamically creating fuctions calls and
class names from string
a function/class name can be stored as string and called/initilzed
e.g
def foo(a,b):
return...
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these...
|
by: hobbes992 |
last post by:
Howdy folks,
I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or...
|
by: Aaron \Castironpi\ Brady |
last post by:
Hello all,
To me, this is a somewhat unintuitive behavior. I want to discuss the
parts of it I don't understand.
.... f= lambda: n
....
9
9
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |