Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add text at the end of each line ... HELP !
#1
Hello !
I need help for create a macro that adds a word to the end of each line in a txt file.

Here an example:

Original txt file
qwer,asdf,zxcv,,,
xcvb,sdfg,wert,,,
erty,dfgh,cvcvb,,,

New file with word "test" added to all line:
qwer,asdf,zxcv,,,test
xcvb,sdfg,wert,,,test
erty,dfgh,cvcvb,,,test

The file I have to process is composed of over 10 thousand lines.
I can do it even with a "command batch" in a Prompt Windows but, since
the file is generated by QM, I would prefer to have QM do everything.

Any suggestion ? 

Thanks in advance !
#2
Macro Macro356
Code:
Copy      Help
str s=
;qwer,asdf,zxcv,,,
;xcvb,sdfg,wert,,,
;erty,dfgh,cvcvb,,,

ARRAY(str) a=s
int i
for(i 0 a.len) a[i]+"test"
s=a

out s
#3
Thanks Gintaras for fast reply but probably I didn't explain myself well.


I have one file name " example.txt " ( he is located in directory c:\desktop )

In this file there are about 10 thousand line as follow :

asdf,fdsa,zxcv,,,
1233,qwewdssd,qwerw,,,
9a8id,109274,asdf,,,
lkjh,df,ksajdfds,,,
and so on 

I need to write the word " test " at the end of each line (all are in the same file)

The new "example.txt" file will be :
asdf,fdsa,zxcv,,,test
1233,qwewdssd,qwerw,,,test
9a8id,109274,asdf,,,test
lkjh,df,ksajdfds,,,test

I need to add the word test to each of the contents of the file and overwrite the old file (or generate a new one with name "Complete").

Waiting and thanks for your invaluable help !
#4
Macro Macro4
Code:
Copy      Help
str s.getfile("$desktop$\example.txt.txt")

ARRAY(str) a=s
int i
for(i 0 a.len) a[i]+"test"
s=a

s.setfile("$desktop$\Complete.txt")
#5
Hi Win,

Today I learned some more... it's work perfect !

Thanks a lot !


Forum Jump:


Users browsing this thread: 1 Guest(s)