Data import
Posted: Wed Nov 30, 2011 1:29 pm
Hi
I am trying to import data from a csv file into a datagrid which I have done with the following code:
What I need to do now, is upload the data from the csv file into 1 column of the datagrid withought going over/replacing any of the data from the other columns of the datagrid.
If anyone could help I would be most grateful.
Thanks
Daniel
I am trying to import data from a csv file into a datagrid which I have done with the following code:
Code: Select all
on mouseUp
local tFileName, tFileContents
answer file "Please choose a file to import" with type "Comma Separated Values|csv|CSV"
if the result is not "cancel" then
put it into tFileName
## Get the contents of the file
put URL ("file:" & tFileName) into tFileContents
## Display the file contents in the field
put line 1 of tFileContents into tColumnTitles
replace comma with return in tColumnTitles
//set the dgProp[ "columns" ] of group "MobileNumbersDataGrid" to tColumnTitles
end if
replace comma with tab in tFileContents
set the dgText[true] of group "MobileNumbersDataGrid" to tFileContents
## Get the complete data
put the DGData of grp "MobileNumbersDataGrid" into tArray
## Set the data of the datagrid back to the now modified array
set the DGData of grp "MobileNumbersDataGrid" to tArray
end mouseUp
If anyone could help I would be most grateful.
Thanks
Daniel