PDA

View Full Version : load tab text file into datagrid help please


4thstar
10-10-2006, 11:56 AM
hello guys.
i have been supplied a set of datafiles , some only 60 listings , some over 3000 listings.

i have the datagrid plugin and would like to load the data from the file into the datagrid.

i know enough to manipulate data once its been added , adding vat etc but i get so lost as to how to do 2 things.

1st: load the data into the datagrid from the file thats tab delimited.(.txt)
2nd:after my changes save the file back out as comma delimited. (.csv)

i have attached the smallest sample data file i have , can someone please advise.

Kind Regards
Carl

Worm
10-10-2006, 05:56 PM
I threw this together really quick, didn't do much error testing, but it should get you on track.

TJ_Tigger
10-11-2006, 07:49 AM
I posted some functions a while back that allow you to import a csv file to a table. Might help get you started.

Post (http://www.indigorose.com/forums/showpost.php?p=89479&postcount=6)

Tigg

4thstar
10-11-2006, 11:42 AM
hey worm and tj , many thanks for the help and advice , thats great , i was going round in small circles :) i know it wasnt going to be to much code , i just couldnt quite work it out :)

changing/editing once in the datagrid is ok for me :) i just got stuck on the code for getting the data into the grid..

i will now look at how to get it back out as a comma delimited csv :)

Many thanks
Kind regards
carl

Worm
10-11-2006, 12:25 PM
A little starter code


sOut = ""
for nRow = 1 , DataGrid.GetRowCount("Grid1") do
sLineOut = ""
for nCol =1, DataGrid.GetColumnCount("Grid1") do
sLineOut=sLineOut..DataGrid.GetCellText("Grid1", nRow, nCol)..","
end
sLineOut = String.Mid(sLineOut, 1, (String.Length(sLineOut) - 1)) .. "\r\n"
sOut = sOut .. sLineOut
end

TextFile.WriteFromString("Autoplay\\Docs\\Output.csv", sOut, false)
sOut = ""

Intrigued
10-11-2006, 07:24 PM
A little starter code


sOut = ""
for nRow = 1 , DataGrid.GetRowCount("Grid1") do
sLineOut = ""
for nCol =1, DataGrid.GetColumnCount("Grid1") do
sLineOut=sLineOut..DataGrid.GetCellText("Grid1", nRow, nCol)..","
end
sLineOut = String.Mid(sLineOut, 1, (String.Length(sLineOut) - 1)) .. "\r\n"
sOut = sOut .. sLineOut
end

TextFile.WriteFromString("Autoplay\\Docs\\Output.csv", sOut, false)
sOut = ""


Useful code chunk. :yes