ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

macro to edit a .txt file?

(1/4) > >>

bit:
I could sure use a simple program snack or 'macro' that allows me to delete numbers 0 thru 9, and the quote marks, in a .txt file, with just a few clicks.  :-*

Ath:
There are dozens ways of doing that, I've supplied one in my last NANY: NANY 2015 Entry: SedTester

AbteriX:
Or utilize PowerShell, it's already there.

FROM: PoShTest.txt
"Virtualisierte Medien"

"Virtualisierte Medien" sind bei der Verwendung der Hyper-V-Virtualisierung ein wichtiger
Computern. Vieles der Hyper-V-Technologie ist zwar in Windows 8 neu, aber virtualisierte

Hyper-V unter Windows Server 2012

Bei Hyper-V unter Windows 8 und unter Windows Server 2012 handelt es sich im Prinzip um
Computern. Virtuelle Computer lassen sich leicht von Windows Server 2012 auf Windows 8
--- End quote ---


TO: PoShTestOUT1.txt
Virtualisierte Medien

Virtualisierte Medien sind bei der Verwendung der Hyper-V-Virtualisierung ein wichtiger
Computern. Vieles der Hyper-V-Technologie ist zwar in Windows  neu, aber virtualisierte


Hyper-V unter Windows Server

Bei Hyper-V unter Windows  und unter Windows Server  handelt es sich im Prinzip um
Computern. Virtuelle Computer lassen sich leicht von Windows Server  auf Windows
--- End quote ---



USE:

# With PS-default "Unicode Encoding" output:
C:\Temp> Get-Content .\PoShTest.txt | ForEach-Object{ $_ -replace'\d|"'} > PoShTestOUT1.txt


# Like "-Encoding ASCII" but with localized Umlauts or accent support
C:\Temp> Get-Content .\PoShTest.txt | ForEach{ $_ -replace'\d|"'} | Out-File -Encoding Default PoShTestOUT2.txt


EDIT: remove digit-surrounding spaces also:
C:\Temp> Get-Content .\PoShTest.txt | ForEach{ $_ -replace' ?\d+ ?|"'} | Out-File -Encoding Default PoShTestOUT2.txt
' ?\d+ ?|"' Means: space-or-not ( ?) + one-or-more digits (\d+) + space-or-not ( ?)     OR    an single double-quote sign (")





--- ---PowerShell Out-File Help excerpt:
  -Encoding <String>
      Specifies the type of character encoding used in the file. Valid values are "Unicode", "UTF7", "UTF8",
      "UTF32", "ASCII", "BigEndianUnicode", "Default", and "OEM". "Unicode" is the default.
      "Default" uses the encoding of the system's current ANSI code page.



Shorter:
C:\Temp> gc .\PoShTest.txt|%{$_ -replace'\d|"'}|out-file -enc default PoShTestOUT2.txt

bit:
^With apology, I tried Sed and even viewed a nice yt 'how to' about it, but it seems a little too technical for me.
Tnx just the same.

bit:
I thought of a possible alternate method to eliminate numbers, but it won't work so far.
My desired application is to use TextAssist v.4.0 (i.e. TA) for text-to-speech playback on text that has every line consecutively numbered.
TA allows the use of specialized 'speech dictionaries' (suffix '.tad') in which you can set it up to substitute words in speech.
For instance, a hypothetical 'block.tad' speech dictionary may be selected, and the word 'cube' in print, can be set up to be spoken as 'block'.
Thus; "I found a cube," in print, would be spoken, "I found a block."
So I tried creating a 'no numbers.tad' speech dictionary, and entered numbers 0 through 9, with no spoken equivalent, the idea being to induce TA to say nothing when encountering numbers.

But some entries seem to be hard-wired, and the attempt failed.
I've tried to find where these hard-wired entries are located in a TA program file, without success.
If I could open and edit the hard-wired entry list, perhaps a separate copy of TA might be set up, with a backup original copy preserved.

So it was a thought, but I have no idea how it might be done.

Navigation

[0] Message Index

[#] Next page

Go to full version