467,146 Members | 1,020 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,146 developers. It's quick & easy.

can slurp do this?

hello

Say I am interested in users giving me values for a, b, c and d.

I have a file with all the results - a very big file!

user 1
a: one
b: two
d: four

user 2
a: one
b: two
c: three
d: four

etc etc

and want to create a file

user a b c d
1 one two x four
2 one two three four

etc etc

How do I put in an x for c for user 1, indicating that this user
didn't submit a value for c?

I slurping the way to do it?

Cheers

Geoff
Jul 16 '08 #1
  • viewed: 1258
Share:
2 Replies
Geoff Cox <gc**@freeuk.notcomwrote:
>hello

Say I am interested in users giving me values for a, b, c and d.

I have a file with all the results - a very big file!

user 1
a: one
b: two
d: four

user 2
a: one
b: two
c: three
d: four

etc etc

and want to create a file

user a b c d
1 one two x four
2 one two three four

etc etc

How do I put in an x for c for user 1, indicating that this user
didn't submit a value for c?

I slurping the way to do it?
No need for slurping in the whole file. If you know the set of all a, b,
c, d, ... in advance then just go ahead and create the top row. Then
read in the information for each user and print the row for him.
If you don't know the set of all a, b, c, ... in advance then read the
file twice: first pass just to determine the set of a, b, c, ... and the
second pass as above.

jue
Jul 16 '08 #2
On Wed, 16 Jul 2008 13:51:15 GMT, Jürgen Exner <ju******@hotmail.com>
wrote:
>Geoff Cox <gc**@freeuk.notcomwrote:
>>hello

Say I am interested in users giving me values for a, b, c and d.

I have a file with all the results - a very big file!

user 1
a: one
b: two
d: four

user 2
a: one
b: two
c: three
d: four

etc etc

and want to create a file

user a b c d
1 one two x four
2 one two three four

etc etc

How do I put in an x for c for user 1, indicating that this user
didn't submit a value for c?

I slurping the way to do it?

No need for slurping in the whole file. If you know the set of all a, b,
c, d, ... in advance then just go ahead and create the top row. Then
read in the information for each user and print the row for him.
If you don't know the set of all a, b, c, ... in advance then read the
file twice: first pass just to determine the set of a, b, c, ... and the
second pass as above.

jue
thanks Jue - will give this a try.

Cheers

Geoff
Jul 16 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by James | last post: by
5 posts views Thread by Scott D | last post: by
2 posts views Thread by Nick | last post: by
2 posts views Thread by Alexander Ross | last post: by
reply views Thread by Dan Foley | last post: by
5 posts views Thread by Lee Redeem | last post: by
5 posts views Thread by christopher vogt | last post: by
6 posts views Thread by Phil Powell | last post: by
1 post views Thread by Michel | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.