Alodar
Active Members-
Posts
63 -
Joined
-
Last visited
About Alodar
- Birthday 11/20/1980
Profile Information
-
Location
Bay Area, California
Alodar's Achievements
Wayfarer (2/7)
0
Reputation
-
I'd love to do that, but unfortunately I'm only allowed to submit csv files to it. Unless there's a faster way to read the xml (300mb), then I don't know what to do. I like the idea of using regex to read it line by line, but will that be qualitatively faster than using the XML dom?
-
Indded. What I have is a context with mutiple (variable number) of subset items within it that i need to split. e.g. <projects> <projectlist> <projectid>Project1</projectid> <tasks> <task>Code1</task> <taskinfo>blah blah</taskinfo> <taskinfo2>blah blah</taskinfo2> <taskinfo3>blah blah</taskinfo3> <task>Code2</task> <taskinfo>blah blah</taskinfo> <taskinfo2>blah blah</taskinfo2> <taskinfo3>blah blah</taskinfo3> </tasks> </projectlist> <projectlist> <projectid>Project2</projectid> <tasks> <task>Code1</task> <taskinfo>blah blah</taskinfo> <taskinfo2>blah blah</taskinfo2> <taskinfo3>blah blah</taskinfo3> <task>Code2</task> <taskinfo>blah blah</taskinfo> <taskinfo2>blah blah</taskinfo2> <taskinfo3>blah blah</taskinfo3> </tasks> </projectlist> </projects> And it's a huge list; 1000 items+. My current plan of using XML.au3 and then looping through each 'set' and placing it in arrays and then writing it to separate csvs (one for tasks and their info, and one for project id's and it's info - it has info the same way the tasks do) works, but it's a bit slow. Perhaps clunky? Dunno, but i can't think of a faster / smoother way to do it?
-
A script I've written runs every single time I personally run it, whether as an exe or in Scite. However, sometimes when I go to check on it (it runs periodically from a scheduled task) I'll come across it with an error saying that there was an error: variable used without being declared. Except, I have Opt("MustDeclareVars", 1) set, and so thus, every variable has to be declared, right? So how does this come up? I've never managed to get this error to come up when I run it in Scite, so I'm at a loss as to how to hunt down what's causing it. Suggestions or advice for me anyone?
-
XML.au3 - BETA - Support Topic
Alodar replied to mLipok's topic in AutoIt Projects and Collaboration
Removed, since I sort of solved this myself finally. -
Mostly it's that. I have control over it once I download it etc, but as for creating it from the source data or anything else, no, I have no control. It's a file sent to me that I then have to manipulate.
-
Yeah. I was more asking for what 'should' I do as a concept, rather than a 'how'. Dealing with an XML file in and of itself is ok, and the UDF listed would work great for it, I was just wondering if there was a better method than my original thought of creating different arrays for 'parent' and 'child' items. Eventually, the xml data I deal with will be going in to tables, so the most effective way to deal with it is kind of what I'm after.
-
So I've been dealing with a lot of xml files lately, and I end up converting them to csvs and the like, and then putting them into a database. Which is fine, but honestly, the process bothers me. I'm not quite up to writing my own xml parser, so obviously I'd want to use MSXML or something like that, but I'd like to get some advice on structure. Obviously, if this is something I should be picking up a book on, please tell me and if you're feeling generous, even tell me which book I should be reading, but what I'd like to get to is how to parse out an xml file into separate structures; i.e. the parent items and child items into different arrays (or variables?). This is the part I'm not sure about; how I should be parsing it out. I feel like the obvious answer is to parse it into a set of arrays with one being the 'parent' and the other(s?) being the child elements, which I would know ahead of time from the schema, but is there a better method that I'm just not aware of?
-
So, i find myself often lately writing small loops to try doing a function multiple times (such as downloading a file, testing to see whether it downloaded correctly or not, and retrying if not because of various connection issues and timeouts), and I was thinking of writing a function to do it for me, but maybe it's bad practice? For example: Local $x = 0 While $x < 5 $iReturnVal = _SomeFunc(param1, param2) If $iReturnVal = 1 then ExitLoop EndIf $x += 1 WEnd But what I'd like to do is something more along the lines of this: $iLoopVal = _TryLoop(_SomeFunc(param1, param2)) Func _TryLoop(_FuncName(Params)) Local $x = 0 While $x < 5 $iReturnVal = _FuncName(Params) If $iReturnVal = 1 then Return 1 EndIf $x += 1 WEnd Return SetError(1, 0, 0) EndFunc So that I can just call that function without having to write the loop every time. I suspect that that's probably bad coding, but i don't know. Heck, I don't even know if it's possible. So, first, can it be done, and second, if yes (or maybe even if no) should or should not I do that?
-
I keep needing to do date calculations, and I keep having dates in nowhere near the format that AutoIt's integrated functions can deal with, so I finally had to write a function to format dates back into the proper format. Thought I'd share. Maybe someone will neaten it up, or show a shorter way, but this is how I did it. To be fair, the error settings aren't done (because I always know whether it's going to be a failure beforehand or not), so I should fix that, but there it is.. Func _ProperDate($sDateTime, $sFormat, $sDelimiter = "/", $sYear = "20") ; #FUNCTION# ;=============================================================================== ; ; Name...........: _ProperDate ; Description ...: Extracts file/folder from ZIP compressed file ; Syntax.........: _ProperDate($sDate, $sFormat, $sDelimiter = "/", $sYear = "20" ; Parameters ....: $sDate - Date string ; $sFormat - Format of String (MDY, MYD, YMD, YDM, DMY, DYM) ; $sDelimiter - Delimiter string ("/", ",", "%20", etc) ; $sYear - Determines whether the beginning points of the year should start with 19 or 20 ; Return values .: Success - Returns proper date format for calculations YYYY/MM/DD[ HH:MM:SS] ; Failure - Returns 0 sets @error: ; |1 - Bad Format ; |2 - Date is Invalid ; Author ........: dwright ; example........: _ProperDate("11/20/1980", "MDY") ;========================================================================================== Local $sDate = StringRegExpReplace($sDateTime, " \d{1,2}:\d{1,2}:\d{1,2} [A|P]M", "") Local $sTime = " " & StringStripWS(StringReplace($sDateTime, $sDate, ""), 3) Local $aDate = StringSplit($sDate, $sDelimiter, 1) Local $i For $i = 1 To 3 If StringLen($aDate[$i]) = 1 Then $aDate[$i] = "0" & $aDate[$i] EndIf Next Switch $sFormat Case "MDY" If StringLen($aDate[3]) = 2 Then $aDate[3] = $sYear & $aDate[3] EndIf Return StringStripWS($aDate[3] & "/" & $aDate[1] & "/" & $aDate[2] & $sTime, 3) Case "MYD" If StringLen($aDate[2]) = 2 Then $aDate[2] = $sYear & $aDate[2] EndIf Return StringStripWS($aDate[2] & "/" & $aDate[1] & "/" & $aDate[3] & $sTime, 3) Case "YMD" If StringLen($aDate[1]) = 2 Then $aDate[1] = $sYear & $aDate[3] EndIf Return StringStripWS($aDate[1] & "/" & $aDate[2] & "/" & $aDate[3] & $sTime, 3) Case "YDM" If StringLen($aDate[1]) = 2 Then $aDate[1] = $sYear & $aDate[3] EndIf Return StringStripWS($aDate[1] & "/" & $aDate[3] & "/" & $aDate[2] & $sTime, 3) Case "DMY" If StringLen($aDate[3]) = 2 Then $aDate[3] = $sYear & $aDate[3] EndIf Return StringStripWS($aDate[3] & "/" & $aDate[2] & "/" & $aDate[1] & $sTime, 3) Case "DYM" If StringLen($aDate[2]) = 2 Then $aDate[2] = $sYear & $aDate[3] EndIf Return StringStripWS($aDate[2] & "/" & $aDate[3] & "/" & $aDate[1] & $sTime, 3) EndSwitch EndFunc ;==>_ProperDate
-
I have a bunch of files that I'm working with, but I keep running into files wherein they have escaped strings. The files are delimited with different things - commas, bars, tabs, etc - and _FileReadToArray has been my easiest method of working with them. However, lately they've started to 'escape' strings in the files, but not consistently. For instance, one time a line will read like: 1, 2, "Third item, is here", 4, "fifth detail", """Another Line here is "OK"""" and another will read as: 1, 2, 'Third item, is here', 4, 'fifth detail', "Sometimes there's a sixth" etc I haven't come across anything where they're trying to escape the lines as weird things like @ symbols or the like (yet), but I could see it, since the people creating the files are allowed to choose their own escape characters (WHY?!). I've currently been manually creating the 2D arrays with some StringRegExp arrays, but I'd love to find a way to add update or bastardize the _FileReadToArray function with an option for an escape character so that it's dynamic and I don't have to keep recreating this stuff by hand. Anyone got an idea for me?
-
So I have a bit of code where I'm sending a (very large) xml string via a POST command to a site. Except, I think it's timing out. Not quite sure, perhaps it's not, and I just have it written wrong? All I get in SCITE is Error in this kind of orange text (not the usual black). My responsetext and status and statustext don't come back as anything, so I'm kind of at a loss as to how to troubleshoot past this. Anyone have an idea for me? (I had to hide the site and dbid in the quickbase URL as it's my company, so I can't post it for confidentiality reasons). $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", http://<mysite>.quickbase.com/<mydbid>, False) $oHTTP.SetRequestHeader("Content-Type", "application/xml") $oHTTP.SetRequestHeader("QUICKBASE-ACTION", "API_ImportFromCSV") $oHTTP.Send($xmlStr) $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status ConsoleWrite(IsObj($oReceived) & @CRLF) ConsoleWrite(IsObj($oStatusCode) & @CRLF) ConsoleWrite($oStatusCode & @CRLF) ConsoleWrite($oReceived & @CRLF) the $xmlStr is an XML string / file that is 62MB...I'm thinking the size is part of the problem, but I really can't cut it down. I'm hoping I can just find a way to retrieve a status for when it timed out or didn't work or something, but since I'm getting nothing except that weird orange Error in Scite, not quite sure what to do.
-
Smtp Mailer That Supports Html And Attachments.
Alodar replied to Jos's topic in AutoIt Example Scripts
You are sure that: - MailServer IP address used is correct. - Yes - You have the SMTP service Enabled on your Mailserver. - To my knowledge - You allow the SMTP for the PC/Server you are sending the Email from. - To my knowledge Have you checked the Server's Logs to see what is happening? - Can't, not mine What kind of mailserver are you running? - Gmail Is this a local or a Provider's Mailserver? - Provider's Have you tried sending an EMail with for example OutlookExpress to this server just to test SMTP? - Yes Have you tested with Regular SMTP with the CDO UDF? - No, not quite sure on that. I use the one provided, and it worked fine before, but now the only result I get is the transport failed to connect to the server. That's why it's odd to me, it USED to work? Could something have changed? -
The problem I have with StringSplit and _FileReadLine is that many of the fields I am dealing with have user comments, and thus have commas as well as CRLF's (or LF's or CR's depending on who's entering it), and so can't really trust that to be an actual 'split'. Many of the csv readers I've seen coded out here don't seem to account for that, and I get broken lines or mis-marked columns/fields.