Hi, how can I do the following ..
After doing some research I believe this is possible with the NEOBOOK "StrParse" function & a loop code but I'm not sure how to go about it.
--
Have a text file full of data which is exported from a spreadsheet.
I want to file read every row and create a new file which contains x amount of rows together within a newly created .pls or .m3u file. In other words, I'll have a button which will scan the document & output a new document with an assigned extension containing associated data formatted properly within rows.
In this case, I want every 3 rows to be contained within a separate file, how can I program it to loop through the entire document until every 3 rows becomes an individual .pls or .m3u file ?
I'm trying to create custom .pls and .m3u files with the detected data for the amount of rows I instruct it to keep together within a new .pls or .m3u file.
Example
SPREADSHEET EXPORTED TO .TXT CONTAINS ..
OPTION1
file1=http://109.69.2.44:7500/stream/1/
title1=Club FM Tirana Live
OPTION2
file2=http://23.95.51.84:9999
title2=COOLcelsius 91.5
OPTION3
file3=http://89.105.32.27:80/metro128.mp3
title3=Metro Oslo
I want to click a button & get separate playlist files.
Example
STATION1.pls or STATION1.m3u file
OPTION1
file1=http://109.69.2.44:7500/stream/1/
title1=Club FM Tirana Live
STATION2.pls or STATION2.m3u file
OPTION2
file2=http://23.95.51.84:9999
title2=COOLcelsius 91.5
STATION3.pls or STATION3.m3u
OPTION3
file3=http://89.105.32.27:80/metro128.mp3
title3=Metro Oslo
Thanks for the help!
Creating new files from a document containing data sets ??
Moderator: Neosoft Support
-
- Posts: 18
- Joined: Thu Aug 21, 2014 4:21 am
-
- Posts: 419
- Joined: Thu Oct 15, 2009 3:43 pm
Re: Creating new files from a document containing data sets
Code: Select all
FileToVar "![PubDir]data.txt" "[file]"
StrParse "[file]" "OPTION" "[option]" "[n]"
Loop "2" "[n]" "[i]"
SetVar "[j]" "[i]-1"
FileWrite "![PubDir]STATION[j].m3u" "All" "OPTION[option[i]]"
Endloop
-
- Posts: 18
- Joined: Thu Aug 21, 2014 4:21 am
Re: Creating new files from a document containing data sets
I'll give that a shot! Thanks!
I came up with the following which allowed me to create the splits exactly as I visualized it using the word "title" as a delimiter.
Of course, it only works because the word "title" is in every data block I need to split but your method is probably more efficient across all documents. NEOBOOK auto generated the array variables using the "StrParse" function & I'm working on processing each array to create the new playlists.
CODE
StrParse "[RAW_PLAYLIST]" "title" "[array]" "[pcount]"
The parsed count confirmed it worked as intended.
Again, thanks for your help! : )
I came up with the following which allowed me to create the splits exactly as I visualized it using the word "title" as a delimiter.
Of course, it only works because the word "title" is in every data block I need to split but your method is probably more efficient across all documents. NEOBOOK auto generated the array variables using the "StrParse" function & I'm working on processing each array to create the new playlists.
CODE
StrParse "[RAW_PLAYLIST]" "title" "[array]" "[pcount]"
The parsed count confirmed it worked as intended.
Again, thanks for your help! : )
Re: Creating new files from a document containing data sets
Maybe this can help you.
Two ways for answer your question
BUTTON MAKE "PLS" FILES
AND BUTTON 2 MAKE "M3u FILES" WITH DIFFERENT WAY
From Costa Rica
PURA VIDA
WE ARE LEGEND
Two ways for answer your question
BUTTON MAKE "PLS" FILES
Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=3
Name=BtPls
X=85
Y=122
W=90
H=35
Anchor=0
Text=MakePls
Align=2
ImageStyle=0
ObjAction=.. I Wrote File "Data.Txt" with this data¶¶.OPTION1¶.file1=http://109.69.2.44:7500/stream/1/¶.title1=Club FM Tirana Live¶.OPTION2¶.file2=http://23.95.51.84:9999¶.title2=COOLcelsius 91.5¶.OPTION3¶.file3=http://89.105.32.27:80/metro128.mp3¶.title3=Metro Oslo¶¶filelen "[PubDir]Paja\Data.txt" "[len]"¶SetVar "[STATION]" "1"¶¶loop "1" "[len]" "[line]"¶ fileread "[PubDir]Paja\Data.txt" "[line]" "[dt1]"¶ filewrite "[PubDir]Paja\STATION[Station].pls" "All" "[dt1]"¶¶ math "[line]+1" "" "[line]"¶ fileread "[PubDir]Paja\data.txt" "[line]" "[dt2]"¶ filewrite "[PubDir]Paja\STATION[Station].pls" "Append" "[dt2]"¶¶ math "[line]+1" "" "[line]"¶ fileread "[PubDir]Paja\data.txt" "[line]" "[dt3]"¶ filewrite "[PubDir]Paja\STATION[Station].pls" "Append" "[dt3]"¶¶ math "[Station]+1" "" "[Station]"¶endloop
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=7
Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=3
Name=BtM3u
X=187
Y=121
W=90
H=35
Anchor=0
Text=Make M3u
Align=2
ImageStyle=0
ObjAction=..Lines for "GROUP"¶setvar "[TotLines]" "3"¶¶SetVar "[Station]" "1"¶filelen "[PubDir]Paja\Data.txt" "[len]"¶¶loop "1" "[Len]" "[nLine]"¶... First time "ALL"¶ setvar "[Do]" "All"¶ setvar "[LineDt]" "[nLine]"¶ loop "1" "3" "[ReadLine]"¶ fileread "[PubDir]Paja\data.txt" "[LineDt]" "[Data]"¶ filewrite "[PubDir]Paja\STATION[Station].m3u" "[do]" "[Data]"¶... Next Data to "APPEND"¶ setvar "[Do]" "Append"¶ math "[LineDt]+1" "" "[LineDt]"¶ endloop¶ math "[nLine]+[TotLines]-1" "" "[nLine]"¶ math "[Station]+1" "" "[Station]"¶endloop
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=6
PURA VIDA
WE ARE LEGEND
COSTA RICA
PURA VIDA
PURA VIDA