Importing data from tabbed delimited files

Irv Kalb Irv at furrypants.com
Tue Sep 16 00:25:24 CDT 2008


Hi,

Long time Director developer, just starting to use Valentina.  I'm 
porting a set of old applications from V12 to Valentina.

My client creates a number of text files by building spreadsheets in 
Excel, then exporting them as tabbed delimited files.  I want to run 
through this set of files, and build a table for each file.  I found 
the ImportText command in the Import_Export example and I'm hoping 
that this is the proper way to do this.

I have created a database file and I want to read a simple file 
called "Feedback", which consists of just two text strings in each 
line, like this:

POSITIVE	NEGATIVE
Excellent	No way
Good job	Sorry
Great going	Oops
Good	Incorrect
That's right	Try again

The file is called "Feedback.txt" and is in the same directory as the 
application.  Here is the code that I am trying to use:

   oFeedbackTable = gDb.createTable("Feedback")
   if CheckValError() then exit

   lPos = oFeedbackTable.createStringField("POSITIVE", 40)
   if CheckValError() then exit

   lNeg = oFeedbackTable.createStringField("NEGATIVE", 40)
   if CheckValError() then exit

   curs = gDB.SqlSelect( "SELECT * FROM Feedback WHERE FALSE" )
   curs.ImportText(the moviePath & "Feedback.txt", TAB, numToChar(13), "", TRUE)

Everything seems fine up to the ImportText command.  When that 
executes, I get an error for every line saying that the cursor is 
read only:

 R O   c u r s o r   :   T r y i n g   t o   a d d   r e c o r d . 
 E x c e p t i o n   c a t c h e d   d u r i n g   i m p o r t   o f  
 t h e   r e c o r d   a t   l i n e   :   1 .   R e a s o n :  
 C u r s o r   " 1 "   i s   r e a d   o n l y . 


  So I go to the documentation and it says:

Note:  The Cursor must have the flag CanBeUpdated set to TRUE.


But unfortunately, this flag is not documented anywhere else in the 
manual.  So I tried to add a line that says:

   curs.CanBeUpdated = TRUE

right before the curs.ImportText(...)

But when I do that, I get a property not found dialog box saying that 
it cannot find CanBeUpdated.

Two questions:

1)  Is using the ImportText call the proper way to read in a TAB 
delimited file (produced from Excel)?  If not is there an easy way to 
do this, or do I have to parse all the data and build the table item 
by item?

2)  If ImportText is the proper way to do this, what line do I use to 
set the CanBeUpdated flag to TRUE?

Thanks in advance,

Irv


-- 

Multimedia R Us


More information about the Valentina mailing list