Sorry, I'm a Newbie to LC
![Smile :)](./images/smilies/icon_smile.gif)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
marksmithhfx wrote:BTW, after reading Richard's examples of processing CSV I'm even more impressed with how easy it is to import a tab delimited file into a datagrid and display it in LC. For the record, here are 4 lines of code that will do that (the only prep is that you must drag a datagrid onto a card and specify the column names in the property inspector):
answer file ""
put url ("file:" & it) into theData
put true into firstLineContainsColumnNames -- or false, depending
set the dgText[firstLineContainsColumnNames] of group "DataGrid 1" to theData
Tip: if you have column names in your data (i.e. specify TRUE above) you can rearrange how LC displays the columns by specifying a different order in the property inspector. If your named columns are a, b, c and you specify c, b, a in the inspector, LC will display them in the order you specify. Pretty slick.
or "set the dgText[false]..." just to see if anything gets into the datagrid.put url ("file:" & it) into theData
set the dgText[TRUE] of group "DataGrid 1" to theData
Hm, so obviously "the first line did not contain column names"!derr1ck wrote:I just changed
answer file "/path/to/file/myfile.csv"
put url ("file:" & it) into theData
put false into firstLineContainsColumnNames -- or false, depending
set the dgText[false] of group "Display" to theData
and it worked !
Derrick, you might try using the datagrid to view/browse data, even select a record for edit/entry but do the actual manipulation using other tools and techniques (like using edit/entry forms). Search for CRUD on this list (create, read, update, delete) which is a very extensive sqlite example created by townsend. You''ll want to find a msg from townsend that has a file attachment you can download (there is one on Mon May 30th, but there may be others). There is also a video demo available (might still be available from here: http://dl.dropbox.com/u/35256958/CRUD-Example-video.mp4)derr1ck wrote:Ah, Now Just one more thing..............
How can I now save the data form the datagrid to a new sqlite/mysql file.
I'm trying to build an inventory program and have so far transferred contents from a excel file and now want to populate a sqlite or mysql database with that data and then allow a user to continue adding new content to the database.