[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
RE: [sqr-users] Reading from a tab delimited file
- Subject: RE: [sqr-users] Reading from a tab delimited file
- From: "Aguirre, Jose" <JAguir@lsuhsc.edu>
- Date: Wed, 4 Oct 2006 14:00:56 -0500
- Delivery-date: Wed, 04 Oct 2006 15:03:53 -0400
- In-reply-to: <C852F4914A306E47A4164876318083F802D429E3@mpmail1>
- List-id: "This list is for discussion about the SQR database reportinglanguage from Hyperion Solutions." <sqr-users.sqrug.org>
- Thread-index: Acbn5Zf8+sjFoI+/RfShSz6GSNB73wAAP4WA
- Thread-topic: [sqr-users] Reading from a tab delimited file
1-First open the file:
!----------------------------------------------------------------------!
! Procedure: Open-Flat-File !
! Desc: This procedure opens the file that will be read from. !
!----------------------------------------------------------------------!
begin-procedure Open-Flat-File
DISPLAY ' Open-Flat-File '
let $newfile = 'folder_path\file.txt'
open $newfile as 1 for-reading record=700:vary status=#secondfile
if #secondfile != 0
let $error_lit = 'error opening file'
display $error_lit (0,+2)
display $file ()
else
let $file_open = 'Y'
display 'successful opening file'
end-if
END-PROCEDURE
2- Extract the data:
!----------------------------------------------------------------------!
! Procedure: Extract-Row !
! Desc: This procedure reads the data from the flat file. !
!----------------------------------------------------------------------!
begin-procedure Extract-Row
DISPLAY ' Extract-Row '
while not #end-file
let $RecordData = ' '
read 1 into $RecordData:500
Let $RecordData = ltrim(rtrim($RecordData,' '),' ')
let #space = instr($RecordData,' ',1)
extract $var1 from $RecordData 0 5 (position and char. Length)
extract $var2 from $RecordData 11 6
extract $var3 from $RecordData 20 5
Let $var1 = ltrim(rtrim($var1,' '),' ')
Let $var2 = ltrim(rtrim($2,' '),' ')
Let $var3 = ltrim(rtrim($var3,' '),' ')......and so on.
DISPLAY ' END-Extract-Row '
end-procedure
Good luck,
José A. Aguirre
-----Original Message-----
From: sqr-users-bounces+jaguir=lsuhsc.edu@sqrug.org
[mailto:sqr-users-bounces+jaguir=lsuhsc.edu@sqrug.org] On Behalf Of Ryan, David
Sent: Wednesday, October 04, 2006 1:48 PM
To: sqr-users@sqrug.org
Subject: [sqr-users] Reading from a tab delimited file
Hello,
I'm trying to read from a tab delimited .txt file and insert values into
variables.
I do not now know what the length of each field within the file is.
Could someone provide an example that would allow me to start at the beginning
of a line, read from the beginning to the first tab, insert into a variable;
read from the first tab to second tab, insert into a variable.....and so on...
thanks
The information contained in this email is strictly confidential and subject to
the Confidentiality Notice at http://www.stratosglobal.com/email-privacy.html
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users