473,512 Members | 15,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
2 1354
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3328
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company...
5
2738
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to...
2
2711
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form...
2
2528
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") ||...
0
3258
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records...
5
3193
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
10035
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function...
6
2653
by: Phil Powell | last post by:
Ok guys, here we go again! SELECT s.nnet_produkt_storrelse_navn FROM nnet_produkt_storrelse s, nnet_produkt_varegruppe v, nnet_storrelse_varegruppe_assoc sv, nnet_produkt p WHERE...
1
2182
by: Michel | last post by:
a site like this http://www.dvdzone2.com/dvd Can you make it in PHP and MySQL within 6 weeks? If so, send me your price 2 a r a (at) p a n d o r a . b e
0
7252
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7371
Oralloy
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,...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5676
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.