Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Required in ImportFile function. 1

Status
Not open for further replies.

abhijit74

Programmer
Oct 1, 2003
16
US
I have to import a tab delimited text file into a datawindow. My import has to start from the second column in the datawindow. After the import, the first column has to be populated with a hard-coded constant. How do I do this? I am using Powerbuilder version 6.5 and Oracle 8.1.7

I am new to Powerbuilder. Please help.

Cheers!
Abhijit
 
So, you have a tab delimited file like this (using a '|' in place of a tab in this example):
1|2|3|4
7|4|7|2

and you want it to be in the datawindow as

row col 1 col 2 col 3 col 4 col 5
1 1 2 3 4
2 7 4 7 2

and then assign a value to column 1 for each row?

use:
long ll_rows
long ll_i
ll_rows = datawindow.importfile(filename,1,9999,1,4,2)

/* If you happen to know the number of rows in your file use it instead of the 9999 in the above example. */

IF ll_rows > 0 THEN
// assign your value to column 1 in the datawindow
FOR ll_i = 1 to ll_rows
datawindow.setitem(ll_i,1,'yourvalue')
NEXT

ELSE
// some error based on the return code from the import
END IF

The online help for importfile method (datawindows) has additional information.
 
Thanks for your prompt reply. I have got different column types in my datawindow including datetype, float type and integer type columns. Does that affect the update method of the datawindow? Do I need to take special care before updating?

Cheers!
Abhijit
 
As long as the data types and order of the DataWindow object's columns match the columns of data in the file there should be no problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top