Startseite › Foren › Deutsches LiveCode-Forum › Datagrid – Import CSV › Antwort auf: Datagrid – Import CSV
Hallo Klaus,
vielen Dank für den Willkommensgruß.
Die 5 Spalten habe ich noch nicht für mein Datagrid erstellt.
Ich dachte, dass diese automatisch eingelesen werden.
Wie erstelle ich diese am besten?
Folgendes Skript habe ich verwendet:
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 „text“ to tColumnTitles
end if
replace semicolon with tab in tFileContents
set the dgText[true] of group „text“ to tFileContents
## Get the complete data
put the DGData of grp „text“ into tArray
## Set the data of the datagrid back to the now modified array
set the DGData of grp „text“ to tArray
end mouseUp
DANKE
Gruß
Andreas