dbTalk Databases Forums  

Reading a file that has spaces in the ID field.

comp.databases.pick comp.databases.pick


Discuss Reading a file that has spaces in the ID field. in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ROB
 
Posts: n/a

Default Reading a file that has spaces in the ID field. - 06-02-2006 , 04:26 PM






I am having a brain freeze.
I want to read a file and the key or id can have spaces in it.
Can someone help.
Here is part of my code.
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""

Oh, this is Unidata version


Reply With Quote
  #2  
Old   
frosty
 
Posts: n/a

Default Re: Reading a file that has spaces in the ID field. - 06-02-2006 , 04:33 PM






ROB wrote:
Quote:
I am having a brain freeze.
I want to read a file and the key or id can have spaces in it.
Can someone help.
Here is part of my code.
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""

Oh, this is Unidata version
No problem with that line of code, even with spaces
in the ID.

What's the problem you are having?

--
frosty




Reply With Quote
  #3  
Old   
ROB
 
Posts: n/a

Default Re: Reading a file that has spaces in the ID field. - 06-02-2006 , 04:40 PM



It is coming back with a blank record.
After the read I check if it is blank and if it is go to the next
record.
An example of the key is AK_FAIRBANKS NORTH STAR

frosty wrote:
Quote:
ROB wrote:
I am having a brain freeze.
I want to read a file and the key or id can have spaces in it.
Can someone help.
Here is part of my code.
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""

Oh, this is Unidata version

No problem with that line of code, even with spaces
in the ID.

What's the problem you are having?

--
frosty


Reply With Quote
  #4  
Old   
ROB
 
Posts: n/a

Default Re: Reading a file that has spaces in the ID field. - 06-02-2006 , 05:06 PM



There are no null items.
We imported a state county table into our system. So it will be a
pretty static table. The id is made up of the state abreviation and the
county name. So all the items have some info.
Glen B wrote:
Quote:
Make sure you don't have a null item with a null ID. Try editing item ""
in that file. If you get one, then delete it and try to find which program
is writing null records with null IDs.

Glen

"ROB" <RSTRUCK (AT) UNACLAD (DOT) COM> wrote in message
news:1149284416.236081.268550 (AT) c74g2000cwc (DOT) googlegroups.com...
It is coming back with a blank record.
After the read I check if it is blank and if it is go to the next
record.
An example of the key is AK_FAIRBANKS NORTH STAR

frosty wrote:
ROB wrote:
I am having a brain freeze.
I want to read a file and the key or id can have spaces in it.
Can someone help.
Here is part of my code.
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""

Oh, this is Unidata version

No problem with that line of code, even with spaces
in the ID.

What's the problem you are having?

--
frosty



Reply With Quote
  #5  
Old   
frosty
 
Posts: n/a

Default Re: Reading a file that has spaces in the ID field. - 06-02-2006 , 05:19 PM



Is it a "DIR" type (native) file or an "F" type (uniData) file?
Are you running uniData atop *nix or Windoze?

You had writ:
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""
....and...
"After the read I check if it is blank and if it is
go to the next record."

So I'm guessing that right after the "READ ST_CNTY_REC..."
line, you have "IF ST_CNTY_REC = '' THEN..." or the like?

You should do something different on the "ELSE" branch, as
the way you have coded it, you cannot determine if the read
was successful, but returned a null record, _or_ if the read
was unsuccessful. You think it's the former, but it sounds
like it's the latter.

--
frosty

ROB wrote:
Quote:
There are no null items.
We imported a state county table into our system. So it will be a
pretty static table. The id is made up of the state abreviation and
the county name. So all the items have some info.

Glen B wrote:
Make sure you don't have a null item with a null ID. Try editing
item "" in that file. If you get one, then delete it and try to find
which program is writing null records with null IDs.

Glen

ROB wrote:
It is coming back with a blank record.
After the read I check if it is blank and if it is go to the next
record.
An example of the key is AK_FAIRBANKS NORTH STAR

ROB wrote:
I am having a brain freeze.
I want to read a file and the key or id can have spaces in it.
Can someone help.
Here is part of my code.
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""

Oh, this is Unidata version



Reply With Quote
  #6  
Old   
ROB
 
Posts: n/a

Default Re: Reading a file that has spaces in the ID field. - 06-02-2006 , 08:30 PM



We have Unidata on top of Windows
After my read I have
IF ST_CNTY_REC <> "" THEN
OUTREP = ST_CNTY_REC<2>
ELSE
DISPLAY A MESSAGE WITH THE KEY
END
I am not at work but I think that it is a F.
Rob
If you want the exact code I can post that also. Just need to log into
work from home.
frosty wrote:
Quote:
Is it a "DIR" type (native) file or an "F" type (uniData) file?
Are you running uniData atop *nix or Windoze?

You had writ:
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""
...and...
"After the read I check if it is blank and if it is
go to the next record."

So I'm guessing that right after the "READ ST_CNTY_REC..."
line, you have "IF ST_CNTY_REC = '' THEN..." or the like?

You should do something different on the "ELSE" branch, as
the way you have coded it, you cannot determine if the read
was successful, but returned a null record, _or_ if the read
was unsuccessful. You think it's the former, but it sounds
like it's the latter.

--
frosty

ROB wrote:
There are no null items.
We imported a state county table into our system. So it will be a
pretty static table. The id is made up of the state abreviation and
the county name. So all the items have some info.

Glen B wrote:
Make sure you don't have a null item with a null ID. Try editing
item "" in that file. If you get one, then delete it and try to find
which program is writing null records with null IDs.

Glen

ROB wrote:
It is coming back with a blank record.
After the read I check if it is blank and if it is go to the next
record.
An example of the key is AK_FAIRBANKS NORTH STAR

ROB wrote:
I am having a brain freeze.
I want to read a file and the key or id can have spaces in it.
Can someone help.
Here is part of my code.
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""

Oh, this is Unidata version


Reply With Quote
  #7  
Old   
Tony Gravagno
 
Posts: n/a

Default Re: Reading a file that has spaces in the ID field. - 06-02-2006 , 09:44 PM



Grabbing here, but I'm wondering if those keys need to be converted to
DOS 8.3 format before they can be used for the read.

Where is variable KEY being assigned? Have you printed it right
before the read to ensure it's a valid key?

Per Frosty's suggestion, you might want to try something more like
this:
* GET KEY OR EXIT
READ ST_CNTY_REC FROM F.ST_CNTY, KEY THEN
GOSUB SET.OUTREP.OR.WHATEVER
END ELSE
GOSUB HANDLE.ERROR
END

Good luck,
Tony

"ROB" <RSTRUCK (AT) UNACLAD (DOT) COM> wrote:

Quote:
We have Unidata on top of Windows
After my read I have
IF ST_CNTY_REC <> "" THEN
OUTREP = ST_CNTY_REC<2
ELSE
DISPLAY A MESSAGE WITH THE KEY
END
I am not at work but I think that it is a F.


Reply With Quote
  #8  
Old   
Bill H
 
Posts: n/a

Default Re: Reading a file that has spaces in the ID field. - 06-04-2006 , 05:52 PM



Rob:

If you do something like (which I'm sure you're doing) I don't understand
the problem:

OPEN "{Some VOC pointer}" TO F.ST_CNTY ELSE STOP 201, "{Some VOC pointer}"
KEY = "AK_FAIRBANKS NORTH STAR"
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""

Assuming the directory where this is stored is readable by UniData, there
should be no problem, as I do this all the time.

Here's what my (VOC) F.ST_CNTY looks like:

001 DIR
002 E:\Temp
003 D_VOC

Bill


"ROB" <RSTRUCK (AT) UNACLAD (DOT) COM> wrote

Quote:
I am having a brain freeze.
I want to read a file and the key or id can have spaces in it.
Can someone help.
Here is part of my code.
READ ST_CNTY_REC FROM F.ST_CNTY, KEY ELSE ST_CNTY_REC = ""

Oh, this is Unidata version




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.