It looks like PB is expecting, by default, a separate delimited csv file (while the "c" from "csv" means "coma" ...).
Add csv! value csv! specified in the ImportString() arguments and it should fix that point (in my test field).
In addition, the columns defined in your data object must match the columns in the csv file (at least for the first columns of interest to you). If there are mode columns in the csv file, they will be ignored. But if you want to get the 1st (or 2nd) and 3rd columns, you need to define the first 3 columns. You can always hide # 1 or # 2 if you don't need it.
By the way, your code has some problems:
- you should always check the return values ββof function calls, such as
FileOpen() , to stop processing in case of a nonexistent / unreadable file - You read the text file twice for the first line: once before
while and the other inside the loop. Or perhaps it is supposed to ignore the first row with column headers?
FWIF, here is a working code based on yours:
string ls_file = "c:\dev\powerbuilder\experiment\data.csv" string ls_text int li_FileHandle, li_fileread, li_count long ll_row li_FileHandle = FileOpen(ls_File) if li_FileHandle < 1 then return end if li_FileRead = FileRead(li_FileHandle, ls_Text) DO WHILE li_FileRead > 0 li_Count ++ ll_row = dw_1.ImportString(csv!,ls_Text,1) li_FileRead = FileRead(li_FileHandle, ls_Text)//read next line Loop fileclose(li_fileHandle)
source share