Hi,
I'm looking for some help, and hoping someone here will have a clue on where to start with this.
what I'm trying to do is read separate text files that are in over 200 folders on a UNC patch, its the same filename in each folder IE:-
\\server01\TEST\Folder1\test.txt
\\server01\TEST\Folder2\test.txt
\\server01\TEST\Folder3\test.txt
Etc
The first line of text is a name, the second is a date. I'm looking to get livecode to search for these files, the put the name into 1 column and the date into the next - then sort into date order.
anyone done something similar or know how to do this?
Thanks in advance
Read txt Files and populate a Table
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Read txt Files and populate a Table
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Read txt Files and populate a Table
And here is your finish . Make a text field. Now make a table field and a button. Put something like this in fld 1:
Now in the button script:
Craig Newman
May I assume this is how your data will come out of the files you read, as per your post?name1
date1
name2
date2
name3
date3
name4
date4
Now in the button script:
Code: Select all
on mouseUp
get fld 1
set the itemDel to tab
repeat with y = 1 to the number of lines of it step 2
put line y of it & tab & line (y+1) of it & return after accum
end repeat
put accum into fld 2
end mouseUp
Re: Read txt Files and populate a Table
You have a list of file to read like this:
Well I'd do:
########CODE#######
put URL "mylistoffiles.txt" into mylist
set itemdel to "\"
repeat for each line tFile in mylist
if there is tFile then
#we must get the file date
set the defaultfolder to (item 1 to -2 of tFile)
put the long files into temp
put line lineoffset(tFile, temp) of temp into temp
put item 5 of temp into modTime
put tFile & comma & modTime & CR after myResultList
end if
end repeat
set itemdel to comma
sort lines of myResultList numeric by item 2 of each
#####END OF CODE#####
Code: Select all
\\server01\TEST\Folder1\test.txt
\\server01\TEST\Folder2\test.txt
\\server01\TEST\Folder3\test.txt
########CODE#######
put URL "mylistoffiles.txt" into mylist
set itemdel to "\"
repeat for each line tFile in mylist
if there is tFile then
#we must get the file date
set the defaultfolder to (item 1 to -2 of tFile)
put the long files into temp
put line lineoffset(tFile, temp) of temp into temp
put item 5 of temp into modTime
put tFile & comma & modTime & CR after myResultList
end if
end repeat
set itemdel to comma
sort lines of myResultList numeric by item 2 of each
#####END OF CODE#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w