Toddy Utomo
Import data from CSV file
August 04, 2009 05:52AM


PROCEDURE ImportCSVdata(sFullFileName is string)

sCsvSeparator is string = ";"
sCsvRow is string
nFileNum is int
nLoop is int
nCol is int
nJumCol is int = 1

// Create a Table Control with the sufficient (more) column
TableDeleteAll(TABLE_Table1)

nFileNum = fOpen(sFullFileName,foRead)
IF nFileNum = -1 THEN
	Error("File not found!")
ELSE
	LOOP
		sCsvRow=fReadLine(nFileNum)
		nCol=1
		FOR nLoop = 1 TO Length(sCsvRow)
			IF sCsvRow[[nLoop]] = sCsvSeparator THEN 
				sCsvRow[[nLoop]] = TAB
				nCol ++
			END
		END
		TableAdd(TABLE_Table1,sCsvRow)
		IF sCsvRow = EOT THEN BREAK
	END
	fClose(nFileNum)
        FOR x = 1 TO TableCount(TABLE_Table1)
             myfield1 = TABEL_Table1.column1[x]
             myfield2 = TABLE_Table1.column2[x]
             ....
             // Put your logic to HAdd or Hmodify here
             ....
        END

END

HTH
Toddy




Edited 2 time(s). Last edit at 08/04/2009 10:34AM by Toddy Utomo.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: