I have documents that are in fact the Zip file which has the format udf. I want to assign the contents of the xml files to the variable. But unzip the zip file and then the contents of the xml file
reading is getting slower. How can I read the xml file directly in the zip.
I couldn't add the Udf extension to the site, so I put it in the zip file.
Reading The Contents Without Opening The Zip File Topic is solved
Re: Reading The Contents Without Opening The Zip File
Code: Select all
yol := gst()
IfEqual,yol,
{
yol=
return
}
StringRight,uzanti,yol,3
IfNotEqual,uzanti,udf
{
yol=
return
}
FileCreateDir,%A_MyDocuments%\UyapPre
FileDelete,%A_MyDocuments%\UyapPre\*
FileCopy,%yol%,%A_MyDocuments%\UyapPre\Onizleme.zip
kaynak = %A_MyDocuments%\UyapPre\Onizleme.zip
hedef = %A_MyDocuments%\UyapPre
;MsgBox, %kaynak% %hedef%
Unzip(kaynak,hedef)
xlmDosyasi = %A_MyDocuments%\UyapPre\content.xml
okuma := FileOpen(xlmDosyasi, "rw", "UTF-8")
sonuc := okuma.Read(2000)
okuma := FileOpen(xlmDosyasi, "h", "UTF-8")
; comment the next line if you want to see x,y as window relative coords
StringSplit, splitEt, yol, `\
Loop, %splitEt0%
{
ayrilanMetin := splitEt%A_Index%
}
MsgBox,,%ayrilanMetin%,%sonuc%,8
return
F5::
ToolTip
return
gst() { ; GetSelectedText or FilePath in Windows Explorer by Learning one
IsClipEmpty := (Clipboard = "") ? 1 : 0
if !IsClipEmpty {
ClipboardBackup := ClipboardAll
While !(Clipboard = "") {
Clipboard =
Sleep, 10
}
}
Send, ^c
ClipWait, 0.1
ToReturn := Clipboard, Clipboard := ClipboardBackup
if !IsClipEmpty
ClipWait, 0.5, 1
Return ToReturn
}
Unzip(Sources, OutDir, SeparateFolders := false)
{
Static vOptions := 16|256
Sources := StrReplace(Sources, "`n", ";")
Sources := StrReplace(Sources, ",", ";")
Sources := Trim(Sources, ";")
OutDir := RTrim(OutDir, "\")
objShell := ComObjCreate("Shell.Application")
Loop, Parse, Sources, `;, %A_Space%%A_Tab%
{
objSource := objShell.NameSpace(A_LoopField).Items()
TargetDir := OutDir
If (SeparateFolders)
{
SplitPath, A_LoopField,,,, FileNameNoExt
TargetDir .= "\" FileNameNoExt
If (!InStr(FileExist(TargetDir), "D"))
FileCreateDir, %TargetDir%
}
objTarget := objShell.NameSpace(TargetDir)
objTarget.CopyHere(objSource, vOptions)
}
ObjRelease(objShell)
}
- Attachments
-
- ScreeenShot.PNG (116.56 KiB) Viewed 3676 times
Re: Reading The Contents Without Opening The Zip File Topic is solved
Response after your PM:
With the standalone 7za tool, you can print the data to stdout for a specific file.
Say you have a zip files_example.zip with:
Test1.txt
Testfile2.xml
MyAmazingDrawing_01.bmp
And you wanted just the data from Testfile2.xml, you can do the following:
With the standalone 7za tool, you can print the data to stdout for a specific file.
Say you have a zip files_example.zip with:
Test1.txt
Testfile2.xml
MyAmazingDrawing_01.bmp
And you wanted just the data from Testfile2.xml, you can do the following:
Code: Select all
data := RunWaitOne("7za.exe e -so files_example.zip Testfile2.xml")
MsgBox % data
; Copied function from https://www.autohotkey.com/docs/commands/Run.htm#Examples
RunWaitOne(command) {
; WshShell object: http://msdn.microsoft.com/en-us/library/aew9yb99
shell := ComObjCreate("WScript.Shell")
; Execute a single command via cmd.exe
exec := shell.Exec(ComSpec " /C " command)
; Read and return the command's output
return exec.StdOut.ReadAll()
}
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Reading The Contents Without Opening The Zip File
joedf wrote: ↑08 Aug 2019, 09:24Response after your PM:
With the standalone 7za tool, you can print the data to stdout for a specific file.
Say you have a zip files_example.zip with:
Test1.txt
Testfile2.xml
MyAmazingDrawing_01.bmp
And you wanted just the data from Testfile2.xml, you can do the following:Code: Select all
data := RunWaitOne("7za.exe e -so files_example.zip Testfile2.xml") MsgBox % data ; Copied function from https://www.autohotkey.com/docs/commands/Run.htm#Examples RunWaitOne(command) { ; WshShell object: http://msdn.microsoft.com/en-us/library/aew9yb99 shell := ComObjCreate("WScript.Shell") ; Execute a single command via cmd.exe exec := shell.Exec(ComSpec " /C " command) ; Read and return the command's output return exec.StdOut.ReadAll() }
Thank you it works great.
There is only one boredom. When you read thousands of files with the loop, the cmd screen comes and goes. can't I hide cmd screens?
Edit: Bu sorun çözüldü. Lexikosun eski forumda paylaştığı bir çözüm.
Code: Select all
DllCall("AllocConsole")
WinHide % "ahk_id " DllCall("GetConsoleWindow", "ptr")
Last edited by hasantr on 08 Aug 2019, 15:44, edited 1 time in total.
Re: Reading The Contents Without Opening The Zip File
It does not read as UTF-8. So the characters are not legible. Can StdOut read as utf-8?
Thank you very much indeed. Thanks to you, I can do great things, and I'm motivated to learn more. Thank you.thank you.
Thank you very much indeed. Thanks to you, I can do great things, and I'm motivated to learn more. Thank you.thank you.
Re: Reading The Contents Without Opening The Zip File
There's probably a better way to loop through the things you need to do, but you could try just replacing " /C " with " /Q /C ".
The quite or Echo off option for cmd.
For utf8, it might be better to just extract the files to a temporary folder.
The quite or Echo off option for cmd.
For utf8, it might be better to just extract the files to a temporary folder.
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Reading The Contents Without Opening The Zip File
Thank you. Cmd is no longer a problem, I guess.
But the necessity of UTF-8 disappointed me.
Could that be the solution? I didn't really understand what they were doing.
https://www.autohotkey.com/boards/viewtopic.php?f=5&t=6678
Apart from that, I need a formula to clean the teapot that I forgot on the stove before my wife wakes up. The bad part of AHK.
Re: Reading The Contents Without Opening The Zip File
joedf If I take too much time, that 's enough for me. Thanks. I don't want to steal any more of your time.
Re: Reading The Contents Without Opening The Zip File
I guess you could do what Lexikos suggested at the end of that thread. Here is a modified version:
All I did is replace "CP850" with "UTF-8". So change RunWaitOne with StdOutToVar
EDIT:
All I did is replace "CP850" with "UTF-8". So change RunWaitOne with StdOutToVar
Code: Select all
StdOutToVar( sCmd ) { ; GAHK32 ; Modified Version : SKAN 05-Jul-2013 http://goo.gl/j8XJXY
Static StrGet := "StrGet" ; Original Author : Sean 20-Feb-2007 http://goo.gl/mxCdn
DllCall( "CreatePipe", UIntP,hPipeRead, UIntP,hPipeWrite, UInt,0, UInt,0 )
DllCall( "SetHandleInformation", UInt,hPipeWrite, UInt,1, UInt,1 )
VarSetCapacity( STARTUPINFO, 68, 0 ) ; STARTUPINFO ; http://goo.gl/fZf24
NumPut( 68, STARTUPINFO, 0 ) ; cbSize
NumPut( 0x100, STARTUPINFO, 44 ) ; dwFlags => STARTF_USESTDHANDLES = 0x100
NumPut( hPipeWrite, STARTUPINFO, 60 ) ; hStdOutput
NumPut( hPipeWrite, STARTUPINFO, 64 ) ; hStdError
VarSetCapacity( PROCESS_INFORMATION, 16 ) ; PROCESS_INFORMATION ; http://goo.gl/b9BaI
If ! DllCall( "CreateProcess", UInt,0, UInt,&sCmd, UInt,0, UInt,0 ; http://goo.gl/USC5a
, UInt,1, UInt,0x08000000, UInt,0, UInt,0
, UInt,&STARTUPINFO, UInt,&PROCESS_INFORMATION )
Return ""
, DllCall( "CloseHandle", UInt,hPipeWrite )
, DllCall( "CloseHandle", UInt,hPipeRead )
, DllCall( "SetLastError", Int,-1 )
hProcess := NumGet( PROCESS_INFORMATION, 0 )
hThread := NumGet( PROCESS_INFORMATION, 4 )
DllCall( "CloseHandle", UInt,hPipeWrite )
AIC := ( SubStr( A_AhkVersion, 1, 3 ) = "1.0" ) ; A_IsClassic
VarSetCapacity( Buffer, 4096, 0 ), nSz := 0
While DllCall( "ReadFile", UInt,hPipeRead, UInt,&Buffer, UInt,4094, UIntP,nSz, UInt,0 )
sOutput .= ( AIC && NumPut( 0, Buffer, nSz, "UChar" ) && VarSetCapacity( Buffer,-1 ) )
? Buffer : %StrGet%( &Buffer, nSz, "UTF-8" )
DllCall( "GetExitCodeProcess", UInt,hProcess, UIntP,ExitCode )
DllCall( "CloseHandle", UInt,hProcess )
DllCall( "CloseHandle", UInt,hThread )
DllCall( "CloseHandle", UInt,hPipeRead )
Return sOutput, DllCall( "SetLastError", UInt,ExitCode )
}
No worries
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Reading The Contents Without Opening The Zip File
Great, everything works now. Thank you so much.
Re: Reading The Contents Without Opening The Zip File
Glad to hear it.
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Reading The Contents Without Opening The Zip File
Errr... I need more context? Any example file paths, etc.
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Reading The Contents Without Opening The Zip File
Hmmm...
You sure, you're not missing something else?
I just tested a networked path like so
C:\Users\Frost\Desktop>7za e -so \\NetworkDrive01\Path\To\Some\File.7z ArchivedFile.txt
If you test it manually in command prompt, and send me the 7za error. Maybe I can see what the problem is?
You sure, you're not missing something else?
I just tested a networked path like so
C:\Users\Frost\Desktop>7za e -so \\NetworkDrive01\Path\To\Some\File.7z ArchivedFile.txt
If you test it manually in command prompt, and send me the 7za error. Maybe I can see what the problem is?
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Reading The Contents Without Opening The Zip File
That's the end of it. Thank you so much.joedf wrote: ↑16 Aug 2019, 07:41Hmmm...
You sure, you're not missing something else?
I just tested a networked path like so
C:\Users\Frost\Desktop>7za e -so \\NetworkDrive01\Path\To\Some\File.7z ArchivedFile.txt
If you test it manually in command prompt, and send me the 7za error. Maybe I can see what the problem is?
Code: Select all
data := StdOutToVar("7za.exe e -so " chr(34) A_LoopFileFullPath chr(34) " content.xml"
Re: Reading The Contents Without Opening The Zip File
Glad to to see it worked out
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Reading The Contents Without Opening The Zip File
Her seferin 7z.exe tekrar mı açılıyor? I'm working with 30,000 files in size from 2 to 10 kb. The process takes too long. Is there a way to adapt it faster?
Any idea? Thank you so much.
Any idea? Thank you so much.
Re: Reading The Contents Without Opening The Zip File
I think you would have to rethink your approach.
opening and closing a lot of files is generally much slower than a few files that are much larger...
opening and closing a lot of files is generally much slower than a few files that are much larger...
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Who is online
Users browsing this forum: Bing [Bot] and 176 guests