How to replace text in a file
Hi everyone,
I have a txt file and It has some data's. I want to specifically replace a character in the text file. Data's will be like this,
TT=15
S1ST=21601
S1EN=50400
S2ST=50401
S2EN=72000
S3ST=72001
S3EN=21600
GNST=00000
GNEN=00000
S1B1S=22800
S1B1E=23400
S1B2S=28800
S1B2E=30600
S1B3S=36000
S1B3E=36600
S1B4S=45000
S1B4E=46800
In the 2nd line i.e. S1ST=21601, I want to replace 36000 instead of 21601.
After replacing the specific character, data's should overwrite in the file or appending the file will also ok for me.
Give me a suggestion. I am using LV 8.2. So plz post your code in 8.2 ver
Thanks in advance.
Regards,
Vijay
Solved!
Go to Solution.
Check this out.
Edit:- attaching 8.2 version
With Regards
Miraz
Kudos is better option to thank somebody on this forum
Attachments:
String.vi 8 KB
String.vi 8 KB
Similar Messages
-
How to read text in .kep files
hey friends,
how to read text in .kep files
please help me .
with regards,
s.jagadeesh babuHi,
check this link:
http://help.sap.com/saphelp_nw04s/helpdata/en/8f/42a293e35011d29b340000e8a4b41d/content.htm
.kep files are SapShow Training Files. They can be played with sapshow.exe in Knowledge Warehouse.
SAP Show is KW Viewer Application. You can use it to see Kep files. It can be run in windows without the SAP environment. To run SAP Show (4.6D version) you just need 3 files. First is SAP show executable file, another two are Sapstg.dll and ZLib.dll. You can easily find these files on internet.
Regards,
Niraj -
How to insert text in existing file.?????
how to insert text in existing file.?????
my file contains simple text with numbers of lines having more then 10 MB size and it might be increase up to 100MB.
i required to seek to spec. position and insert chunk of characters to file without overwriting existing one.
I tried out with RandomAccessFile class Also.
Pl. Suggest me way to insert String in existing file.
Thanks ,
Timirhow to insert text in existing file.?????You can't "insert" text into an existing file. You can
overwrite portions of an existing file or extend one by
writing past the current end of file.
If you want to insert text into a file you have to write
out a new file. -
How to get Text from (.txt) file to display in the JTextArea ?
How to get Text from (.txt) file to display in the JTextArea ?
is there any code please tell me i am begginer and trying to get data from a text file to display in the JTextArea /... please help...public static void readText() {
try {
File testFile = new File(WorkingDirectory + "ctrlFile.txt");
if (testFile.exists()){
BufferedReader br = new BufferedReader(new FileReader("ctrlFile.txt"));
String s = br.readLine();
while (s != null) {
System.out.println(s);
s = br.readLine();
br.close();
catch (IOException ex){ex.printStackTrace();}
}rykk -
Find & Replace text in html files
This is my first real attempt at using Automator, and it has become increasingly frustrating for me. I love the idea of Automator, nice interface, and it appears to be so easy to use. But, I can't get it to actually DO anything and I don't understand why.
Here is my goal:
to batch process multiple html files to remove certain characters and words (or replace them with empty space).
I currently open these files in Pages and do 6 separate Find & Replace commands for each file before I continue with my other processing tasks. This is very tedious and I believe the computer should be able to find & replace multiple items at one time. (I have used other utilities to do batch renaming and trimming file names before.)
All I want to do is select a group of files (usually 25 at a time) and have Automator get rid of all the unwanted words and characters before I open each file for final processing in Pages. I found a set of Automator actions for TextEdit which includes a Find & Replace action, but I've wasted over an hour so far trying to get it to work.
When I run the workflow, it acts like it's doing something, but the files remain unchanged. I have tried using actions such as Read Text File, Get Contents of TextEdit Document, Set Contents of TextEdit Document, along with 6 instances of Find & Replace, but I cannot get it to work.
I'm at a point today where I cannot afford to mess around with this anymore. I have to do it the long way in Pages or else I'll never get it done, but I want to get these Automator workflows to work before I have to repeat this task. (I do this at least once a week right now.)
Any ideas or suggestions? I've tried reading in the help menus and support pages, but perhaps I'm just not understanding something here.Any ideas or suggestions?
You might be interested in using TextWrangler. It can perform batch find-and-replace changes across multiple selected files.
Good luck!
Andrew99 -
How to control text for PDF Files in the BI7.0 Broadcaster
Hi ,
I am running a web template in the BI7.0 Broadcaster. The output prints in the PDF format. In the precalculation tab I have set up 4 variables(VAR1,VAR2 .. etc) . The main folder where these PDF files get stored I can control the text but dont know how to change the PDF file names which fall into this folder. All the PDF files have the technical name and number(like XXX_00000,XXX_00001 etc.) How can I control the text for these files.
Thanks,
KalHI Kal,
it is not possible to get any influence on the filenames. If you use Filternavigation the filename is generated to be unique.
best regards,
kai -
How to justify text in a file?
How do I right justify text in a file? For example:
Checking 500
Savings 50
Loan 300
NetWorth 1000
Insurance 1000
This is how I want my file to be formatted when it is created. Does anyone know of a way to right justify the numbers? I tried to use the "\t", tab but it doesn't work.
ThanksThere is no magical way to do this. Tabs can be treated differently be every editor. You must add spaces between the title and the amount yourself.
If, however, you are going to display the text file in a JTextPane then you could delimit the title and amount with a tab character and then configure the JTextPane to right justify the amount. -
How to replace bytes in a file?
How to replace some bytes in a file without rewriting it entirely?
bye
aldoI repeat my question:I repeat my answer...
java.io.RandomAccessFile.
Have a look at the java doc! -
How to replace a line in file Java
Hi,
I want to replace a line in file sequencial.
I read file, but i don't know how to replace one line..
Thanks...I supose this..
I usea a FileReader and BufferedReader to read a file.
I read a line, I know the number of the line, but how to say to method println o write what it's the line to replace? -
Hi, may anyone tell me how to append text to a file's end?
every time when i using FileOutputStream.write(byte[]) to add text to a file, the old content would be disappear. but my intention is append, not affect the old content. how to?
thanxassuming it is a text file, read the text into a Reader, read the Reader's contents into a StringBuffer, close the Reader, append to the StringBuffer the new text and write it down to the file.
regards -
How to replace text in smartforms.
Hi,
i had requirement to replace text retail invoice with Tax/sale invoice *** delivery challan in smart form
in that smart form they had retun one condition like region no notequl to '06' they had retun one condition to print correct like(Tax/sale invoice *** delivery challan) but region eq 6 they had return one condition it is printing retail invoice.so he want at any condition u need to print like (Tax/sale invoice *** delivery challan) so any body plz help me
thnks in advance.
sivarama.Hi,
I want print invoice form like.
amount 400000
basic.exice(%) 200000
add:output vat 12.5%
add:output vat 2.50%
so
out put is comming like
I want print invoice form like.
amount 400000
basic.exice(%) 200000
12.5%
2.50%
add:output vat
add:output vat
so how i will do modification for that -
How do I find and replace text in PHP files?
How can I in CS3 make sitewide changes to the text in PHP pages without changing variable names etc that have the same name?
For example if I have an installation of a PHP forum and I want to change every instance of the word 'forum' to 'message board'...
If I used the 'inside tag' search with " as the tag, then if "" contained a variable called 'forum' it would also be changed and therefore corrupt the code....
Is there a simple way around this?
Thanks!
I'm using CS3 on Windows Vista.It looks like you're trying to find and replace source code, so you may be able to look at the various places that are looked at when finding and uncheck the ones that don't apply.
But, if it's all source code then that won't help. One thing that may work is to expand the search option - for example if the work "forum" that you're wanting to change it preceded by another word, or character or something that sets it apart, then do you find on that. You can expand that search phrase as far out in either direction that you need to to make it different, if of course that is practical in your situation.
The only other way I can think of is to somehow create an exception rule, but I'm not sure if that's possible or how to do it. -
Find and Replace text in several files
Can automator do that?
I made a website in iweb and as the ones of you that had already tried it must know, it is impossible to change the font format on the links, you have to hack the code manually, changing the .css files.
I think a trick would be to get automator to replace the code automatically, to lock for a string of text inside a group of files and save it. I just don't know how to do it. Can anybody help?
The most I have been able to do is to get automator to open all .css files within a folder, inlcuidng all subfolders and open them on textedit.I doubt anyone is going to download and look at your code. Please remember that anyone who helps you here is a volunteer, and so the onus is on you to make helping you as easy as possible to do. That means you must take the effort to pare your code down to the bare minimum that shows your problem and compiles, and then post this code here. If you do decide to do this, please use code tags by highlighting your code after pasting it, and then pressing the Code button just above the editor window.
Good luck. -
Help with Replacing text in a file using a vbscript
I have the following script which I am wanting to
1. Take the prf file and read it
2. Edit a line in the outlook .prf file replacing it with the text I have asked it to replace which is the full name of the user pulled from the currently logged on user
The problem I am seeing is that when the temp file is being generated it is throwing off the formatting of the file hence the script doesn't work. Can anyone help me please.
set objSysInfo = CreateObject("ADSystemInfo")
struser = objSysInfo.Username
set objUser = GetObject("LDAP://" & strUser)
strFullName = objUser.Get("displayName")
Const ForReading=1
Const ForWriting=2
Set objFSO = CreateObject("Scripting.FileSystemObject")
folder = "C:\test"
'filePath = folder & "file.txt"
filePath = "c:\test\test2007_3.prf"
Set myFile = objFSO.OpenTextFile(filePath, ForReading)
Set myTemp= objFSO.OpenTextFile(filePath & ".tmp", ForWriting, True)
Do While Not myFile.AtEndofStream
myLine = myFile.ReadLine
If InStr(myLine, "MailboxName=%UserName%") Then
myLine = "&strFullName"
End If
myTemp.WriteLine myLine
Loop
myFile.Close
myTemp.Close
objFSO.DeleteFile(filePath)
objFSO.MoveFile filePath& ".tmp", filePath
ChristopherSorry Irv,
Here is the code I have and then after that is the prf file. I think there is an issue with the file structure because if I take a regular text file and add the lines in there myself it replaces the lines, but with the prf file or even the prf file as a
text file it gives me the invalid argument message
Const filePath = "c:\test\test2007_3.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set myFile = objFSO.OpenTextFile(filePath)
fileText = myFile.ReadAll()
myFile.Close
fileText=Replace(fileText,"%UserName%","THIS_IS_THS_REPLACEMENT_TEXT")
Set myTemp= objFSO.OpenTextFile(filePath, 2, True)
myTemp.Write fileText
myTemp.Close
;Automatically generated PRF file from the Microsoft Office Customization and Installation Wizard
; Section 1 - Profile Defaults
[General]
Custom=1
ProfileName=Somthing
DefaultProfile=Yes
OverwriteProfile=Yes
ModifyDefaultProfileIfPresent=false
DefaultStore=Service1
; Section 2 - Services in Profile
[Service List]
ServiceX=Microsoft Outlook Client
ServiceEGS=Exchange Global Section
Service1=Microsoft Exchange Server
ServiceEGS=Exchange Global Section
; Section 3 - List of internet accounts
[Internet Account List]
; Section 4 - Default values for each service.
[ServiceX]
CachedExchangeMode=0x00000002
CachedExchangeSlowDetect=true
[ServiceEGS]
CachedExchangeConfigFlags=0x00000900
MailboxName=%UserName%
HomeServer=
RPCoverHTTPflags=0x0027
RPCProxyServer=
RPCProxyPrincipalName=
RPCProxyAuthScheme=0x0001
[Service1]
OverwriteExistingService=No
UniqueService=Yes
MailboxName=%UserName%
HomeServer=
OfflineAddressBookPath=%USERPROFILE%\local settings\application data\microsoft\outlook\
OfflineFolderPathAndFilename=%USERPROFILE%\local settings\application data\microsoft\outlook\outlook.ost
AccountName=Microsoft Exchange Server
DefaultAccount=TRUE
;[ServiceX]
;FormDirectoryPage=
;-- The URL of Exchange Web Services Form Directory page used to create Web forms.
;WebServicesLocation=
;-- The URL of Exchange Web Services page used to display unknown forms.
;ComposeWithWebServices=
;-- Set to true to use Exchange Web Services to compose forms.
;PromptWhenUsingWebServices=
;-- Set to true to use Exchange Web Services to display unknown forms.
;OpenWithWebServices=
;-- Set to true to prompt user before opening unknown forms when using Exchange Web Services.
; Section 5 - Values for each internet account.
; Section 6 - Mapping for profile properties
[Microsoft Exchange Server]
ServiceName=MSEMS
MDBGUID=5494A1C0297F101BA58708002B2A2517
MailboxName=PT_STRING8,0x6607
HomeServer=PT_STRING8,0x6608
OfflineAddressBookPath=PT_STRING8,0x660E
OfflineFolderPathAndFilename=PT_STRING8,0x6610
[Exchange Global Section]
SectionGUID=13dbb0c8aa05101a9bb000aa002fc45a
MailboxName=PT_STRING8,0x6607
HomeServer=PT_STRING8,0x6608
RPCoverHTTPflags=PT_LONG,0x6623
RPCProxyServer=PT_UNICODE,0x6622
RPCProxyPrincipalName=PT_UNICODE,0x6625
RPCProxyAuthScheme=PT_LONG,0x6627
CachedExchangeConfigFlags=PT_LONG,0x6629
[Microsoft Mail]
ServiceName=MSFS
ServerPath=PT_STRING8,0x6600
Mailbox=PT_STRING8,0x6601
Password=PT_STRING8,0x67f0
RememberPassword=PT_BOOLEAN,0x6606
ConnectionType=PT_LONG,0x6603
UseSessionLog=PT_BOOLEAN,0x6604
SessionLogPath=PT_STRING8,0x6605
EnableUpload=PT_BOOLEAN,0x6620
EnableDownload=PT_BOOLEAN,0x6621
UploadMask=PT_LONG,0x6622
NetBiosNotification=PT_BOOLEAN,0x6623
NewMailPollInterval=PT_STRING8,0x6624
DisplayGalOnly=PT_BOOLEAN,0x6625
UseHeadersOnLAN=PT_BOOLEAN,0x6630
UseLocalAdressBookOnLAN=PT_BOOLEAN,0x6631
UseExternalToHelpDeliverOnLAN=PT_BOOLEAN,0x6632
UseHeadersOnRAS=PT_BOOLEAN,0x6640
UseLocalAdressBookOnRAS=PT_BOOLEAN,0x6641
UseExternalToHelpDeliverOnRAS=PT_BOOLEAN,0x6639
ConnectOnStartup=PT_BOOLEAN,0x6642
DisconnectAfterRetrieveHeaders=PT_BOOLEAN,0x6643
DisconnectAfterRetrieveMail=PT_BOOLEAN,0x6644
DisconnectOnExit=PT_BOOLEAN,0x6645
DefaultDialupConnectionName=PT_STRING8,0x6646
DialupRetryCount=PT_STRING8,0x6648
DialupRetryDelay=PT_STRING8,0x6649
[Personal Folders]
ServiceName=MSPST MS
Name=PT_STRING8,0x3001
PathAndFilenameToPersonalFolders=PT_STRING8,0x6700
RememberPassword=PT_BOOLEAN,0x6701
EncryptionType=PT_LONG,0x6702
Password=PT_STRING8,0x6703
[Unicode Personal Folders]
ServiceName=MSUPST MS
Name=PT_UNICODE,0x3001
PathAndFilenameToPersonalFolders=PT_STRING8,0x6700
RememberPassword=PT_BOOLEAN,0x6701
EncryptionType=PT_LONG,0x6702
Password=PT_STRING8,0x6703
[Outlook Address Book]
ServiceName=CONTAB
[LDAP Directory]
ServiceName=EMABLT
ServerName=PT_STRING8,0x6600
UserName=PT_STRING8,0x6602
UseSSL=PT_BOOLEAN,0x6613
UseSPA=PT_BOOLEAN,0x6615
EnableBrowsing=PT_BOOLEAN,0x6622
DisplayName=PT_STRING8,0x3001
ConnectionPort=PT_STRING8,0x6601
SearchTimeout=PT_STRING8,0x6607
MaxEntriesReturned=PT_STRING8,0x6608
SearchBase=PT_STRING8,0x6603
CheckNames=PT_STRING8,0x6624
DefaultSearch=PT_LONG,0x6623
[Microsoft Outlook Client]
SectionGUID=0a0d020000000000c000000000000046
FormDirectoryPage=PT_STRING8,0x0270
WebServicesLocation=PT_STRING8,0x0271
ComposeWithWebServices=PT_BOOLEAN,0x0272
PromptWhenUsingWebServices=PT_BOOLEAN,0x0273
OpenWithWebServices=PT_BOOLEAN,0x0274
CachedExchangeMode=PT_LONG,0x041f
CachedExchangeSlowDetect=PT_BOOLEAN,0x0420
[Personal Address Book]
ServiceName=MSPST AB
NameOfPAB=PT_STRING8,0x001e3001
PathAndFilename=PT_STRING8,0x001e6600
ShowNamesBy=PT_LONG,0x00036601
; Section 7 - Mapping for internet account properties. DO NOT MODIFY.
[I_Mail]
AccountType=POP3
;--- POP3 Account Settings ---
AccountName=PT_UNICODE,0x0002
DisplayName=PT_UNICODE,0x000B
EmailAddress=PT_UNICODE,0x000C
;--- POP3 Account Settings ---
POP3Server=PT_UNICODE,0x0100
POP3UserName=PT_UNICODE,0x0101
POP3UseSPA=PT_LONG,0x0108
Organization=PT_UNICODE,0x0107
ReplyEmailAddress=PT_UNICODE,0x0103
POP3Port=PT_LONG,0x0104
POP3UseSSL=PT_LONG,0x0105
; --- SMTP Account Settings ---
SMTPServer=PT_UNICODE,0x0200
SMTPUseAuth=PT_LONG,0x0203
SMTPAuthMethod=PT_LONG,0x0208
SMTPUserName=PT_UNICODE,0x0204
SMTPUseSPA=PT_LONG,0x0207
ConnectionType=PT_LONG,0x000F
ConnectionOID=PT_UNICODE,0x0010
SMTPPort=PT_LONG,0x0201
SMTPSecureConnection=PT_LONG,0x020A
ServerTimeOut=PT_LONG,0x0209
LeaveOnServer=PT_LONG,0x1000
[IMAP_I_Mail]
AccountType=IMAP
;--- IMAP Account Settings ---
AccountName=PT_UNICODE,0x0002
DisplayName=PT_UNICODE,0x000B
EmailAddress=PT_UNICODE,0x000C
;--- IMAP Account Settings ---
IMAPServer=PT_UNICODE,0x0100
IMAPUserName=PT_UNICODE,0x0101
IMAPUseSPA=PT_LONG,0x0108
Organization=PT_UNICODE,0x0107
ReplyEmailAddress=PT_UNICODE,0x0103
IMAPPort=PT_LONG,0x0104
IMAPUseSSL=PT_LONG,0x0105
; --- SMTP Account Settings ---
SMTPServer=PT_UNICODE,0x0200
SMTPUseAuth=PT_LONG,0x0203
SMTPAuthMethod=PT_LONG,0x0208
SMTPUserName=PT_UNICODE,0x0204
SMTPUseSPA=PT_LONG,0x0207
ConnectionType=PT_LONG,0x000F
ConnectionOID=PT_UNICODE,0x0010
SMTPPort=PT_LONG,0x0201
SMTPSecureConnection=PT_LONG,0x020A
ServerTimeOut=PT_LONG,0x0209
CheckNewImap=PT_LONG,0x1100
RootFolder=PT_UNICODE,0x1101
[INET_HTTP]
AccountType=HOTMAIL
Account=PT_UNICODE,0x0002
HttpServer=PT_UNICODE,0x0100
UserName=PT_UNICODE,0x0101
Organization=PT_UNICODE,0x0107
UseSPA=PT_LONG,0x0108
TimeOut=PT_LONG,0x0209
Reply=PT_UNICODE,0x0103
EmailAddress=PT_UNICODE,0x000C
FullName=PT_UNICODE,0x000B
Connection Type=PT_LONG,0x000F
ConnectOID=PT_UNICODE,0x0010
Christopher -
How to replace a string in file
if a file's content is:
aaa 123 456
bbb 341 343
ccc 343 233
now i want to replace 341 with 768
how?
& use which classes? thx!I would suggest
java.io*;
Use a beffered Reader, read the file, and output into another one
Maybe you are looking for
-
Need Help to update the labels in the GUI syncronously - Swing application
Hello everyone, I need some help regarding a swing application. I am not able to syncronously update the counters and labels that display on my Swing GUI as the application runs in the background. But when the running of application is completed, the
-
6.0.2.23 import new cd's - lose artwork from tracks already in library
Upgraded to 6.0.2.23 successfully and this rev fixed Outlook synching glitches, but now when I import new cd's I lose artwork from tracks that are already in my library. All cover art has been added manually via get info-paste artwork, sometimes 1 tr
-
APD vs Read from a cube using Function module
Hi, Please could someone tell me which is the best practice for the below case: I want to sent information for one cube to another and in the transformation read from a third cube. I think I have this two options: - Option1: In the transformatio
-
I need help reinstalling a licensed Photoshop Elements 7 without a disk.
I have a licensed and registered version of Photoshop Elements 7. After I let iYogi "optimize" my system, I can no longer open this program. I don't have the disk any longer. Can someone help direct me on how to fix/reinstall this program without lo
-
How Can I know, Material status does not allow purchase??
Hi Experts, Pls. clarify me that, How Can I know/track the follwoing things? Which tables I hv to see? I hv a list of materials, some r good , some r bad. So, I hv to trace out the bad materials depending on the criteria, So, pls. let me know Which t