Jump to content

Recommended Posts

Posted (edited)

Some time ago I ask How to Read/Display file content - non txt file ?.

here is my new version:

Example()

Func Example()

    Local $hTimer = 0
    Local $sText = ''

    $hTimer = TimerInit()
    $sText = _GetTextFromTextStream(@ScriptDir & "\TEST123_Polish.skk")
    MsgBox(0, '# of lines = ' & @extended & ' in ' & Round(TimerDiff($hTimer) / 1000, 3) & ' sec.', $sText)

    $hTimer = TimerInit()
    $sText = _GetTextFromTextStream(@ScriptDir & "\TEST123_Polish.skk", False)
    MsgBox(0, '# of lines = ' & @extended & ' in ' & Round(TimerDiff($hTimer) / 1000, 3) & ' sec.', $sText)

    ; the text should be like this
    #cs
        Polish Diacritic mark: ąćęłńóśżź
        English: acelnoszz
    #ce


EndFunc   ;==>Example

; #FUNCTION# ====================================================================================================================
; Name ..........: _GetTextFromTextStream
; Description ...: Get text from binary file.
; Syntax ........: _GetTextFromTextStream($sFileFullPath[, $bGetAsLine = True])
; Parameters ....: $sFileFullPath       - a string value.
;                  $bGetAsLine          - [optional] a boolean value. Default is True.
; Return values .: Text or set @error to non zero
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _GetTextFromTextStream($sFileFullPath, $bGetAsLine = True)
    Local Const $iForReading = 1, $iForWriting = 2, $iForAppending = 3
    Local Const $iTristateUseDefault = -2, $iTristateTrue = -1, $iTristateFalse = 0

    Local $oFSO = ObjCreate("Scripting.FileSystemObject")
    If @error Then Return SetError(1, 0, '')

    Local $oFile = $oFSO.GetFile($sFileFullPath)
    If @error Then Return SetError(2, 0, '')

    Local $oTS = $oFile.OpenAsTextStream($iForReading, $iTristateUseDefault)
    If @error Then Return SetError(3, 0, '')

    Local $sText = ''
    Local $sTemp = ''
    Do
        If $bGetAsLine Then
            $sText &= $oTS.ReadLine
        Else
            $sText &= $oTS.Read(1)
        EndIf
    Until $oTS.AtEndOfStream

    Local $iLineCounter = $oTS.Line

    $oTS.Close
    $oFile = ''
    $oFSO = ''

    Return SetExtended($iLineCounter, $sText)

EndFunc   ;==>_GetTextFromTextStream

_GetTextFromTextStream.ZIP

Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Nice catch using the Scripting.FileSystemObject object but the output is different compared to link you have provided.

 

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted
Yes, I know. That's life.
But it is enough for me and the speed is just outstanding.
 
mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Thanks for sharing. :thumbsup:

Perhaps you could do a brief list at first post, of the file types this is likely to support (i.e. doc, rtf, pdf, etc). :huh2:

And perhaps what isn't supported ... and a reason maybe? :think:

You don't have to do any of that of course, but I reckon it would be a good idea. :D

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

  Reveal hidden contents

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Posted

i can confirm it supports .doc files (Word 97-2003 format). although along with the text it does produce the entire metadata. a method to trim away the metadata must be specific per file type, i imagine.

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

This function is useful for me to search files based on their content.

I know that there are other methods but require calling other programs.
Unless someone will show me some other native method.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

  On 2/27/2015 at 5:12 PM, JohnOne said:

I'm unsure I understand what this is doing that FileRead is not, apart from stripping EOL chars.

Can you show example with the same *.skk file?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

If you try then you understand.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

I guess I cheat, I use BinaryToString followed by StringRegExp but this is my solution. Tested with your .skk file searching for "LaserJet 1020" which worked, works on PDFs, .xls, .doc (but NOT .xlsx or .docx unfortunately) and many other file types.

Anyhoo, never shared this before, thought this was a good time.

Ian

Edit - posted an updated version, see my sig for the link.

Edited by llewxam

My projects:

  Reveal hidden contents
  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
  • Moderators
Posted

llewxam,

 

  Quote

NOT .xlsx or .docx

See >this post to understand why - and subsequent posts to see how you can still search these file types. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted

Melba23, I know I have said it before, but I love you man!!! :D

I will add a special case to my above app shortly and start a new thread in the Examples section with the updated code.

THANKS!!!

Ian

My projects:

  Reveal hidden contents
  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Posted
  On 2/28/2015 at 8:55 AM, llewxam said:
Anyhoo, never shared this before, thought this was a good time.

Thanks for sharing, and Melba23 beat me to it.

I look forward to what you come up with.

mlipok may even come up with something more expansive now, perhaps incorporating some of your ideas and others ... or both of you will.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

  Reveal hidden contents

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Posted (edited)

  On 2/28/2015 at 8:55 AM, llewxam said:

I guess I cheat, I use BinaryToString followed by StringRegExp but this is my solution. Tested with your .skk file searching for "LaserJet 1020" which worked, works on PDFs, .xls, .doc (but NOT .xlsx or .docx unfortunately) and many other file types.

Anyhoo, never shared this before, thought this was a good time.

Ian

 

I checked.
It works the way I wanted.
It dawned on me.
 
I'll have a few questions, but first I need to formulate them well.
It will take some time, because today I have other tasks to perform (laundry, cleaning, putting the baby to sleep, watch a romantic comedy with my wife EDIT: ... And other interesting things which I will not describe here ...).
 
Best regards,
mLipok
 
Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Cramp it were that simple.

Local $sRead = FileRead(@ScriptDir & '\TEST123_Polish.skk')
$sRead = StringReplace($sRead, Chr(0), ' ')
MsgBox(0, '$sRead', $sRead)

But I'm angry with myself :(

Two years of unnecessary waiting.
Now I can finally make use of my head  :muttley:
 
mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...