Best data import approach

Peter Haworth pete at lcsql.com
Sat Mar 30 21:28:34 EDT 2013


Hi Skip,
It's assigned whenever you add data to the datagrid not when it's sorted,
but I think it's probably easier to add your own line number to the data
after the put and before the set in your script, something like

put zero into x
repeat for each line L in theData
 add 1 to x
  put x & tab before line x of the data
end repeat

Don't know if your file has column names in the first line; if so, you'd
need to put a column name for the line number into line 1.

Then just include a column in the datagrid to hold the line number.

This all assumes that each time you import this file, you're starting off
with an empty datagrid.  If not, you'd have to set x to the max of the line
number column in the datagrid instead of zero.

HTH,


Pete
lcSQL Software <http://www.lcsql.com>


On Sat, Mar 30, 2013 at 5:40 PM, Magicgate Software - Skip Kimpel <
skip at magicgate.com> wrote:

> So the dgIndex is assigned after it is read in and sorted?  I am using the
> simple technique of:
>
> > put "C:\Users\Skip\Desktop\myLog.log" into it
> > put url ("file:" & it) into theData
> > set the dgText of group "MyGrid" to theData
>
> Looks like I might need to approach this thing differently if I want to
> read it in line by line and assign a number to it, right?
>
> SKIP
>
>
>
>
> On Sat, Mar 30, 2013 at 8:06 PM, Peter Haworth <pete at lcsql.com> wrote:
>
> > Datagrids assign a unique dgIndex which stays constant for each line
> after
> > they're sorted but I don't recall any automated way to sort by it.  Maybe
> > you could just add a column to the input after you read it from your file
> > with an incrementing number in it so it would end up as a column in the
> > datagrid (hidden if you prefer it that way).
> >
> > Pete
> > lcSQL Software <http://www.lcsql.com>
> >
> >
> > On Sat, Mar 30, 2013 at 3:52 PM, Magicgate Software - Skip Kimpel <
> > skip at magicgate.com> wrote:
> >
> > > Back to my sorting issue with date and time, quite honestly, the log
> file
> > > is already sorted.... I just need to have the DataGrid display it as it
> > was
> > > read into the system with out trying to do additional sorting.  Is
> there
> > a
> > > way to sort, for instance, by some itemID number that the DataGrid
> > assigns
> > > to it?
> > >
> > > SKIP
> > >
> > >
> > > On Sat, Mar 30, 2013 at 5:51 PM, Magicgate Software - Skip Kimpel <
> > > skip at magicgate.com> wrote:
> > >
> > > > Thank you!  ....
> > > > http://www.fourthworld.com/embassy/articles/csv-must-die.html
> > > >
> > > >
> > > >
> > > >
> > > > On Sat, Mar 30, 2013 at 5:42 PM, Alex Tweedly <alex at tweedly.net>
> > wrote:
> > > >
> > > >> Of course. You can find it best in Richard's excellent article about
> > the
> > > >> evils of CSV format, at
> > > >>
> > > >>
> > http://www.fourthworld.com/**embassy/articles//csv/-/must/-**/die/.html
> > > <http://www.fourthworld.com/embassy/articles//csv/-/must/-/die/.html>
> > > >>
> > > >> It does deal with many of the vagaries, but won't do anything about
> > > >> records with different number of fields (I think that was what you
> > > >> mentioned earlier in the email thread), though it will (AFAIR) deal
> > with
> > > >> embedded CRs if they are within a quoted string.
> > > >>
> > > >> BTW - there is the opportunity for a slightly faster method which
> > avoids
> > > >> the array step - but the difference would only be significant for
> VERY
> > > >> large data sets, so I've not had the incentive to finalize and test
> it
> > > >> thoroughly.
> > > >>
> > > >> -- Alex.
> > > >>
> > > >>
> > > >>
> > > >> On 30/03/2013 20:51, Magicgate Software - Skip Kimpel wrote:
> > > >>
> > > >>> Excellent... Thank you Pete...
> > > >>>
> > > >>> Alex, would you be so kind to share?
> > > >>>
> > > >>> SKIP
> > > >>>
> > > >>>
> > > >> ______________________________**_________________
> > > >> use-livecode mailing list
> > > >> use-livecode at lists.runrev.com
> > > >> Please visit this url to subscribe, unsubscribe and manage your
> > > >> subscription preferences:
> > > >> http://lists.runrev.com/**mailman/listinfo/use-livecode<
> > > http://lists.runrev.com/mailman/listinfo/use-livecode>
> > > >>
> > > >
> > > >
> > > _______________________________________________
> > > use-livecode mailing list
> > > use-livecode at lists.runrev.com
> > > Please visit this url to subscribe, unsubscribe and manage your
> > > subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list