sampy Posted May 6, 2011 Share Posted May 6, 2011 Hi,i have some DAT file loaded in arreyExample:In the temp.dat = numero adulti: 20In the db1.dat = adulti:In the cb1.dat = 'numero adulti:\s(\d*)i want display the number 20 but my result is 1why?i think i have an error in this expression: $valori[$z] = StringRegExp($aRecords[$k],$string2[$j],3)any suggest?Thanksexpandcollapse popupDim $aRecords If Not _FileReadToArray("temp.dat",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf Dim $string If Not _FileReadToArray("db" & $i & ".dat",$string) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf Dim $string2 If Not _FileReadToArray("cb" & $i & ".dat",$string2) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $z = 20 Dim $valori[$z] $z = 1 For $j=1 to $string[0] For $k=1 to $aRecords[0] If StringInStr($aRecords[$k],$string[$j]) Then $valori[$z] = StringRegExp($aRecords[$k],$string2[$j],3) MsgBox(0,$k,"found" & $valori[$z]) $z = $z + 1 ExitLoop EndIf Next Next Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 6, 2011 Moderators Share Posted May 6, 2011 sampy, We showed you exactly how to do this here - why do you not use the code from that thread? 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...
jchd Posted May 6, 2011 Share Posted May 6, 2011 StringRegExp return an array with option 3. See help file. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
sampy Posted May 6, 2011 Author Share Posted May 6, 2011 sampy, We showed you exactly how to do this here - why do you not use the code from that thread? M23 I have used your code... if i use: $a = StringRegExp($var, ':\s(\d*)\z',3) no problem... if i use Dim $string2 If Not _FileReadToArray("cb" & $i & ".dat",$string2) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $a = StringRegExp($var,$string2,3) where $string2 = ':\s(\d*)\z' i have an error why??? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 6, 2011 Moderators Share Posted May 6, 2011 sampy,$string2 is an array returned by _FileReadToArray - you cannot use it in an SRE like this:$a = StringRegExp($var, $string2, 3)You must extract an element of the array to use as the pattern. Perhaps if you post the temp.dat, db1.dat and cb1.dat files and explain how you relate them we might be able to come up with something to help you. 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...
sampy Posted May 6, 2011 Author Share Posted May 6, 2011 sampy, $string2 is an array returned by _FileReadToArray - you cannot use it in an SRE like this: $a = StringRegExp($var, $string2, 3) You must extract an element of the array to use as the pattern. Perhaps if you post the temp.dat, db1.dat and cb1.dat files and explain how you relate them we might be able to come up with something to help you. M23 my temp.dat -----Messaggio originale----- Da: Fabrizio Sampaolo [mailto:fabrizio@campinglamedusa.it] Inviato: giovedì 5 maggio 2011 18:55 A: fabrizio.sampaolo@gmail.com Oggetto: FW: Camping Village La Medusa: richiesta diretta da SVILUPPO TURISMO ITALIA NETWORK (ID30#) ________________________________ From: Riccardo Ghezzi [mailto:rickylidia@yahoo.it] Sent: Tuesday, May 03, 2011 3:15 PM To: info Subject: Camping Village La Medusa: richiesta diretta da SVILUPPO TURISMO ITALIA NETWORK (ID30#) [http://www.campingevillaggi.com/shared-images/mail/logo-sti-200x80.gif] <http://www.sviluppoturismoitalia.it> [http://www.campingevillaggi.com/shared-images/mail/logo-network-200x80.gif] <http://www.campingevillaggi.com/> Sviluppo Turismo Italia > Network Campingevillaggi.com: Le nuove guide dei campeggi e villaggi turistici italiani www.campeggio.com<http://www.campeggio.com/> | www.campeggievillaggi.com<http://www.campeggievillaggi.com/> | www.campingevillaggi.com<http://www.campingevillaggi.com/> www.campinginitaly.it<http://www.campinginitaly.it/> | www.villaggimare.com<http://www.villaggimare.com/> | www.campeggiovillaggio.com<http://www.campeggiovillaggio.com/> Questa e-mail è stata inviata esclusivamente alla sua struttura. Il Sig./Sig.ra Riccardo Ghezzi, richiede la seguente disponibilità: periodo: 14-08-2011 - 27-08-2011 trattamento: pensione completa numero adulti: 20 numero di bambini: 10 età: 2 animali di piccola taglia: no animali di taglia medio/grande: no NOTE AGGIUNTIVE: nessuna Il Sig./Sig.ra Riccardo Ghezzi gradirebbe inoltre ricevere un depliant al seguente indirizzo: via marconi3/c - viganò - 23897 - Lecco PER RISPONDERE AL CLIENTE: Tel.: 3495214834 Mail: rickylidia@yahoo.it<mailto:rickylidia@yahoo.it> commerciale@sviluppoturismoitalia.it<mailto:commerciale@sviluppoturismoitalia.it> IDENTIFICATIVO MAIL: CVN-234167-ID30# my db1.dat numero adulti: numero di bambini: periodo: periodo: periodo: periodo: periodo: periodo: Il Sig./Sig.ra animali di piccola taglia: animali di taglia medio/grande: trattamento: my cb1.dat 'numero adulti:\s(\d*)' 'bambini:\s(\d*)' 'periodo: \s*(\d*).(\d*).\d*' 'periodo: \s*\d*.(\d*).\d*' 'periodo: \s*\d*.\d*.(\d*)' this is a part of my code expandcollapse popupDim $aRecords If Not _FileReadToArray("temp.dat",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf Dim $string If Not _FileReadToArray("db" & $i & ".dat",$string) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf Dim $string2 If Not _FileReadToArray("cb" & $i & ".dat",$string2) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $z = 20 Dim $valori[$z] $z = 1 For $j=1 to $string[0] For $k=1 to $aRecords[0] If StringInStr($aRecords[$k],$string[$j]) Then $valori[$z] = StringRegExp($aRecords[$k],$string2[$j],3) MsgBox(0,$k,"found " & $aRecords[$k]) MsgBox(0,$k,"found " & $string[$j]) MsgBox(0,$k,"found " & $string2[$j]) MsgBox(0,$k,"found" & $valori[$z]) $z = $z + 1 ExitLoop EndIf Next Next MsgBox(0,$i,$aRecords[$i]) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 6, 2011 Moderators Share Posted May 6, 2011 (edited) sampy,OK, I can work with that to get the "adulti" and "bambini" numbers. Just one question: What are you trying to get from the "periodo: 14-08-2011 - 27-08-2011" section? The SREs you are using are not clear. Please give me an example of what you would like to see. Forget it - I can see from the db1 file. M23 Edited May 6, 2011 by Melba23 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...
Moderators Melba23 Posted May 6, 2011 Moderators Share Posted May 6, 2011 sampy,Try this: expandcollapse popup#include <Array.au3> #include <File.au3> Global $aRecords, $aStrings, $aPatterns, $aResults[13] $i = 1 If Not _FileReadToArray("temp.dat",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf If Not _FileReadToArray("db" & $i & ".dat",$aStrings) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf If Not _FileReadToArray("cb" & $i & ".dat",$aPatterns) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf ; Get the non-date data For $i = 1 To 6 ; Look for the string in temp array $iIndex = _ArraySearch($aRecords, $aStrings[$i], 0, 0, 0, 1) ; If we found a match If Not @error Then ; Extract the data from the line $aResults[$i] = StringRegExpReplace($aRecords[$iIndex], $aPatterns[$i], "$1") EndIf Next ; Now extract dates $iIndex = _ArraySearch($aRecords, $aStrings[7], 0, 0, 0, 1) If Not @error Then ; Get array of dates Global $aDates = StringRegExp($aRecords[$iIndex], $aPatterns[7], 3) For $i = 0 To 5 $aResults[7 + $i] = $aDates[$i] Next EndIf ; Display results _ArrayDisplay($aResults)I have modified the order (and number of lines) of the db1.dat file as follows:numero adulti: numero di bambini: Il Sig./Sig.ra animali di piccola taglia: animali di taglia medio/grande: trattamento: periodo:and the patterns in the cb1.dat file now read (we use the final pattern to get all the dates in one go):(?i)(?U).*:\s(.*)\z (?i)(?U).*:\s(.*)\s.*\z (?i).*\.ra\s(.*),.* (?i)(?U).*:\s(.*)\z (?i)(?U).*:\s(.*)\z (?i)(?U).*:\s(.*)\z (\d{2,4})This also made the extraction easier as we need StringRegExp for the dates and StringRegExpReplace for the others. Please ask if you have any questions. 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...
sampy Posted May 7, 2011 Author Share Posted May 7, 2011 I love you Melba!! you are my hero! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 7, 2011 Moderators Share Posted May 7, 2011 sampy, Glad I could help. 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...
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