Loc Posted July 4, 2022 Posted July 4, 2022 I have a txt file on dropbox. In the txt file as follows: 1 | 2 | 3 | 4 | 5 6 | 7 | 8 | 9 | 10 ... How can now read it as Filereadline() using InetRead() function
junkew Posted July 4, 2022 Posted July 4, 2022 What did you try so far? and whats the result? most likely you can get the file and split it further based on cr/lf https://www.autoitscript.com/autoit3/docs/functions/StringSplit.htm FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Developers Jos Posted July 4, 2022 Developers Posted July 4, 2022 My translation of this cryptic question is that there is a file on the Dropbox Website that the OP likes to download with InetGet() ... but that will never work. Maybe one of the Other Web tools out there could do the job. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
rudi Posted July 7, 2022 Posted July 7, 2022 On the PC with Dropbox client installed right click the file you want to download for further processing -> "copy dropbox link" (German: "Dropbox-Link kopieren") You will receive something like this real world URL (I created and shared a file for you in my Dropbox: https://www.dropbox.com/s/oagfd0e314pz3a0/Some-foo-file.txt?dl=0 Replace the 0 at it's end with a 1: https://www.dropbox.com/s/oagfd0e314pz3a0/Some-foo-file.txt?dl=1 #include <Inet.au3> $URL="https://www.dropbox.com/s/oagfd0e314pz3a0/Some-foo-file.txt?dl=1" $Content = _INetGetSource($URL) MsgBox(0,"Content",$Content) Then use StringSplit() as mentioned by @junkew Loc 1 Earth is flat, pigs can fly, and Nuclear Power is SAFE!
Loc Posted July 7, 2022 Author Posted July 7, 2022 (edited) This is how i did it but can you help me to read this return data line by line? Example: Read line 1 then $Data[0][0] = 1 $Data[0][1] = a $Data[0][n] = ... $Data[1][0] =2 $Data[1][1] = e $Data[1][n] = ... $Data[2][0] = 3 $Data[2][1] = x $Data[3][n] = ... #include <InetConstants.au3> #include <String.au3> #include <StringConstants.au3> #include <Array.au3> Local $ReadData = InetRead("http://dl.dropboxusercontent.com/s/h73t2gvwkercmab/Test.txt") $Data = BinaryToString($ReadData) _ArrayDisplay(StringSplit($Data, '|', $STR_ENTIRESPLIT)) Please excuse my English! Edited July 7, 2022 by Loc
rudi Posted July 7, 2022 Posted July 7, 2022 (edited) 1.) InetGetSource() will directly return STRING data (no need to use BinaryToString()) 2) Use StringSplit() to just split the lines. You split to a 2D array: @crlf delimits lines, | delimits collumns. #include <Inet.au3> #include <Debug.au3> $URL="https://www.dropbox.com/s/oagfd0e314pz3a0/Some-foo-file.txt?dl=1" $Content = _INetGetSource($URL) MsgBox(0,"Content",$Content) $aLines=StringSplit($Content,@CRLF,1) _DebugArrayDisplay($aLines) for $L = 1 to $aLines[0] MsgBox(0,"Line " & $L,$aLines[$L]) Next Edited July 7, 2022 by rudi Loc 1 Earth is flat, pigs can fly, and Nuclear Power is SAFE!
Loc Posted July 7, 2022 Author Posted July 7, 2022 Thanks rudi. This is what I did when I got help #include <Inet.au3> #include <String.au3> #include <StringConstants.au3> #include <Array.au3> $URL = "http://dl.dropboxusercontent.com/s/h73t2gvwkercmab/Test.txt" $Content = _INetGetSource($URL) $Data = StringSplit($Content, @CR) For $i = 1 To UBound($Data) - 1 _ArrayDisplay(StringSplit($Data[$i], '|')) Next
rudi Posted July 7, 2022 Posted July 7, 2022 Well, this is now spoon feeding IMHO -- never mind 😇 #include <Inet.au3> #include <Debug.au3> $URL = "http://dl.dropboxusercontent.com/s/h73t2gvwkercmab/Test.txt" $Content = _INetGetSource($URL) MsgBox(0, '', $Content) $aLines = StringSplit($Content, @CRLF,1) ; The first element will hold the number of chunks the sting $Content was split to _DebugArrayDisplay($aLines) For $L = 1 To $aLines[0] MsgBox(0,"Line = " & $L,$aLines[$L]) Next the last but one line is the position where you need to process the separated lines. The rest of the work is now up to you... Earth is flat, pigs can fly, and Nuclear Power is SAFE!
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