Page 1 of 1
Sanity Check
Posted: Wed Nov 22, 2017 9:56 pm
by jfwhite
I have a project that shouldn't be too hard and I will learn a lot, but I want to be sure I have a solid concept. The requirement is to read two text files, then export combinations of that data into three different text files. I think the easiest way would be to import the data into a SQLite database, that would make the extracting much simpler. So I would:
1. Connect to db
2. Create tables
3. Use an answer file dialog to navigate to the text file, and probably put that data into a text field.
4. Somehow get that tab delimited data into the database table.
5. Repeat with file #2.
6. Execute query to manipulate data and place into text fields.
7. Export that data into comma separated files.
So if I'm not missing anything, my biggest question is #4 - how can I get the tab separated text inserted into the table? I'm not finding anything about this specific task online.
If there's a flaw in the general approach feel free to point that out, or otherwise give me any tips or advice that would be helpful. TIA.
Re: Sanity Check
Posted: Thu Nov 23, 2017 3:42 am
by FourthWorld
What are the sizes of the two input files?
Re: Sanity Check
Posted: Thu Nov 23, 2017 4:55 am
by jfwhite
Not large, maybe a few k, but probably 20+ columns each.
Re: Sanity Check
Posted: Thu Nov 23, 2017 4:58 am
by FourthWorld
Do you need a relational database in this conversion process?
Re: Sanity Check
Posted: Thu Nov 23, 2017 5:15 am
by jfwhite
No but I am fluent in SQL and thought it would make constructing the export files easy, especially if the specs change in the future.
In doing more reading it seems like getting the tab separated input files into a data grid would then make it easy to get into the db tables. But I'm very open to any approach you suggest.
Re: Sanity Check
Posted: Thu Nov 23, 2017 5:22 am
by FourthWorld
Read the files, put their contents into variables, do what you need to do to produce the result, write the result to files. I wouldn't bother adding extra steps like putting the data into a datagrid, a database, or even a field. Those are all useful, but only when you need 'em. With small data sets just work with them in variables and you'll have simple code and fast performance.
Re: Sanity Check
Posted: Thu Nov 23, 2017 5:30 am
by jfwhite
Thanks, I'll pick this back up on Friday - can't wait to dig in. Goodnight and enjoy your Thanksgiving.
Re: Sanity Check
Posted: Thu Nov 23, 2017 8:08 am
by FourthWorld
Thank you, and you too.
When you return from holiday you're about to embark on a great adventure....
Re: Sanity Check
Posted: Thu Nov 23, 2017 8:05 pm
by ghettocottage
I have a little application that runs on my server where I write some times/dates onto a text-file, then check it later and update the text. In my mind it was going to be a complicated thing, but once I delved into it, I found it was as simple as:
Code: Select all
#get the most recent status from the time file
put line 1 of URL "file:time" into tLastEvent
put line 2 of URL "file:time" into tDate
put line 3 of URL "file:time" into tTime
...do some stuff, then:
#update the time file
put "down" into line 1 of URL "file:time"
put the date into line 2 of URL "file:time"
put the time into line 3 of URL "file:time"
I love the simplicity of Livecode!
Re: Sanity Check
Posted: Fri Dec 15, 2017 12:34 pm
by MaxV
jfwhite wrote: ↑Wed Nov 22, 2017 9:56 pm
1. Connect to db
2. Create tables
3. Use an answer file dialog to navigate to the text file, and probably put that data into a text field.
4. Somehow get that tab delimited data into the database table.
5. Repeat with file #2.
6. Execute query to manipulate data and place into text fields.
7. Export that data into comma separated files.
You don't need SQL, just text manipulation of livecode.
See
repeat,
itemdel,
TAB.
Re: Sanity Check
Posted: Fri Jan 12, 2018 3:00 pm
by teriibi
HI...
dont know if it could helps but you can check here about one way to Retreive Online DB Tab delimited data ...down to columns fields of your local Stack.
(just a small part of the complete solution)
viewtopic.php?f=12&t=27521#p162474