jorgeng Posted March 31, 2009 Share Posted March 31, 2009 (edited) Hi.I have a new file I want to read and write to an html-file.My last file was handle with success thanks to you folks in forum, see: http://www.autoitscript.com/forum/index.ph...&hl=jorgengThis file is a little bit trickier since i can't manage to see where file starts and ends for every post. Sometimes there is no data in position 1 and sometimes it is.Everywhere I want to have this data on one row: OMXS309D 0 2009033017:19:33 2 620.25 361 Buy 2009033017:20:17The thought is to write output to an html-file which i can access in web-browser. Edited March 31, 2009 by jorgeng Link to comment Share on other sites More sharing options...
jorgeng Posted March 31, 2009 Author Share Posted March 31, 2009 (edited) My try to code this: #include <Array.au3> #Include <Date.au3> $j = 0 While $j <= 0 ; Global $aResult[14][2] = [["", ""], ["Namn", ""], ["Siffra", ""], ["Datum", ""], ["Klockslag", ""], ["Antal Kontrakt", ""], _; ; ["Kurs", ""], ["Siffra", ""], ["Händelse", ""], ["Datum", ""], ["Klockslag", ""], ["Klockslag", ""], ["Klockslag", ""], ["Klockslag", ""]] Global $aResult[24][2] = [["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], _; ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""], ["", ""]] FileWrite($file_Omx_Termins_Avslut, " " & "<br>") $Time = _NowTime() FileWrite($file_Omx_Termins_Avslut, "Time: " & $Time & "<br>") _ArrayDisplay($aResult) FileClose($sString) FileClose($file_Omx_Termins_Avslut) Sleep(30000) Wend Edited March 31, 2009 by jorgeng Link to comment Share on other sites More sharing options...
jorgeng Posted March 31, 2009 Author Share Posted March 31, 2009 (edited) I attach the in-file i use, rename txt to log to make it function or edit source-code.nntransl.txt Edited March 31, 2009 by jorgeng Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2009 Moderators Share Posted March 31, 2009 jorgeng,This code gets your file into a neat array from which you should be able to extract what you need for your HTML page:#include <Array.au3> Local $sData = FileRead(@ScriptDir & "\nntransl.txt") Local $aArray = StringSplit($sData, @TAB) Local $iLines = Int($aArray[0] / 29) + 1 Local $a2D_Array[$iLines][30] Local $k = 1 For $i = 1 To $iLines For $j = 1 to 29 $a2D_Array[$i][$j] = $aArray[$k] $k += 1 If $k = $aArray[0] Then Exitloop(2) Next Next Local $aResult[$iLines][10] = [["Namn", "Siffra", "Datum", "Klockslag", "Antal Kontrakt", "Kurs", "Siffra", "Händelse", "Datum", "Klockslag"]] For $i = 1 To $iLines -1 $aResult[$i][0] = $a2D_Array[$i][4] $aResult[$i][1] = $a2D_Array[$i][5] $aResult[$i][2] = $a2D_Array[$i][7] $aResult[$i][3] = $a2D_Array[$i][8] $aResult[$i][4] = $a2D_Array[$i][11] $aResult[$i][5] = $a2D_Array[$i][13] $aResult[$i][6] = $a2D_Array[$i][18] $aResult[$i][7] = $a2D_Array[$i][21] $aResult[$i][8] = $a2D_Array[$i][23] $aResult[$i][9] = $a2D_Array[$i][24] Next _ArrayDisplay($aResult)I hope I have extracted the correct elements of the file. if not, then use _ArrayDisplay on $2D_Array to see which elements to change in the final For...Next loop.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jorgeng Posted March 31, 2009 Author Share Posted March 31, 2009 jorgeng, This code gets your file into a neat array from which you should be able to extract what you need for your HTML page:#include <Array.au3> Local $sData = FileRead(@ScriptDir & "\nntransl.txt") Local $aArray = StringSplit($sData, @TAB) Local $iLines = Int($aArray[0] / 29) + 1 Local $a2D_Array[$iLines][30] Local $k = 1 For $i = 1 To $iLines For $j = 1 to 29 $a2D_Array[$i][$j] = $aArray[$k] $k += 1 If $k = $aArray[0] Then Exitloop(2) Next Next Local $aResult[$iLines][10] = [["Namn", "Siffra", "Datum", "Klockslag", "Antal Kontrakt", "Kurs", "Siffra", "Händelse", "Datum", "Klockslag"]] For $i = 1 To $iLines -1 $aResult[$i][0] = $a2D_Array[$i][4] $aResult[$i][1] = $a2D_Array[$i][5] $aResult[$i][2] = $a2D_Array[$i][7] $aResult[$i][3] = $a2D_Array[$i][8] $aResult[$i][4] = $a2D_Array[$i][11] $aResult[$i][5] = $a2D_Array[$i][13] $aResult[$i][6] = $a2D_Array[$i][18] $aResult[$i][7] = $a2D_Array[$i][21] $aResult[$i][8] = $a2D_Array[$i][23] $aResult[$i][9] = $a2D_Array[$i][24] Next _ArrayDisplay($aResult) I hope I have extracted the correct elements of the file. if not, then use _ArrayDisplay on $2D_Array to see which elements to change in the final For...Next loop. M23 Thank you very much, it works great... Link to comment Share on other sites More sharing options...
jorgeng Posted April 1, 2009 Author Share Posted April 1, 2009 (edited) I have problems to get the output result on output-file in an array-like structure like you has. Any idea how to format the output-file so it looks like the array display? Now it looks messy like: Rankor System Omx Termins Avslut ------------------------------------- Namn Siffra Datum Klockslag Antal Kontrakt Kurs Siffra Händelse Datum Klockslag OMXS309D 1 20090331 17:25:01 2 643.25 s 20090331 17:25:02 OMXS309D 1 20090331 17:23:05 7 643.25 s 20090331 17:23:05 OMXS309D 1 20090331 17:20:19 2 643.25 s 20090331 17:20:19 OMXS309D 0 20090331 17:19:56 0 643.75 k 20090331 17:19:56 OMXS309D 1 20090331 17:19:32 0 642.50 s 20090331 17:19:32 OMXS309D 0 20090331 17:19:04 0 642.25 k 20090331 17:19:04 OMXS309D 1 20090331 17:18:44 7 642 273 Sell 20090331 17:19:02 OMXS309D 1 20090331 17:18:41 7 641.75 s 20090331 17:18:41 OMXS309D 0 20090331 17:18:17 0 642.75 k 20090331 17:18:17 I would to have it like this: Rankor System Omx Termins Avslut ------------------------------------- Namn Siffra Datum Klockslag Antal Kontrakt Kurs Siffra Händelse Datum Klockslag OMXS309D 1 20090331 17:25:01 2 643.25 s 20090331 17:25:02 Hmm, formatting doesn't work but everywhere, every value in separate column. Edited April 1, 2009 by jorgeng Link to comment Share on other sites More sharing options...
jorgeng Posted April 1, 2009 Author Share Posted April 1, 2009 Strange this forum doesn't handle formatting of strings... Link to comment Share on other sites More sharing options...
jorgeng Posted April 1, 2009 Author Share Posted April 1, 2009 Maybe I can use arraytostring? Link to comment Share on other sites More sharing options...
jorgeng Posted April 1, 2009 Author Share Posted April 1, 2009 (edited) I tried this, but it doesn't work: Local $aResult[$iLines][10] = [["Namn", "Siffra", "Datum", "Klockslag", "Antal Kontrakt", "Kurs", "Siffra", "Händelse", "Datum", "Klockslag"]] MsgBox(0, "_ArrayToString() getting $aResult items 1 to 10", _ArrayToString($aResult[$iLines][10], @TAB, 1, 10)) Edited April 1, 2009 by jorgeng Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 1, 2009 Share Posted April 1, 2009 If your current intention is still to write this out to HTML then I would think that you'll be using an HTML <table> wouldn't you? If you just want to put it up on screen quickly then _ArrayDisplay() will help you. [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
jorgeng Posted April 1, 2009 Author Share Posted April 1, 2009 If your current intention is still to write this out to HTML then I would think that you'll be using an HTML <table> wouldn't you?If you just want to put it up on screen quickly then _ArrayDisplay() will help you.Yes, I will write to file later, but first see how it looks in a messge-box and I can't get it working. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 1, 2009 Moderators Share Posted April 1, 2009 jorgeng,You need to put your text between code tags if you want any sort of formatting in this forum - and even then it is not perfect. :-(This code puts your data in a nice array in a GUI. You cannot use a MsgBox because it will not expand above a certain width and your lines wrap regardless:expandcollapse popupLocal $sData = FileRead(@ScriptDir & "\nntransl.txt") Local $aArray = StringSplit($sData, @TAB) Local $iLines = Int($aArray[0] / 29) + 1 Local $a2D_Array[$iLines][30] Local $k = 1 For $i = 1 To $iLines - 1 For $j = 1 to 29 $a2D_Array[$i][$j] = $aArray[$k] $k += 1 If $k = $aArray[0] Then Exitloop(2) Next Next $sResult = "Namn" & @TAB & @TAB & "Siffra" & @TAB & "Datum" & @TAB & @TAB & "Klockslag" & @TAB & "Antal Kontrakt" & @TAB & "Kurs" _ & @TAB & @TAB & "Siffra" & @TAB & @TAB & "Händelse" & @TAB & "Datum" & @TAB & @TAB & "Klockslag" & @CRLF For $i = 1 To $iLines -1 $sResult &= $a2D_Array[$i][4] & @TAB $sResult &= $a2D_Array[$i][5] & @TAB $sResult &= $a2D_Array[$i][7] & @TAB $sResult &= $a2D_Array[$i][8] & @TAB $sResult &= $a2D_Array[$i][11] & @TAB & @TAB $sResult &= $a2D_Array[$i][13] & @TAB $sResult &= $a2D_Array[$i][18] & @TAB $sResult &= $a2D_Array[$i][21] & @TAB $sResult &= $a2D_Array[$i][23] & @TAB $sResult &= $a2D_Array[$i][24] & @CRLF Next GUICreate("Result", 800, 200) GUICtrlCreateLabel($sResult, 10, 10, 780, 180) GUISetState() While 1 If GUIGetMsg() = -3 Then Exit WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now