I am a new user to Notepad++ (literally just installed the program) and would like to know if it supports advanced scripting like modifying data in a txt file
The problem I have is I need to sort and extract data from text files (reports) that are formatted for legibility rather than being delimited, so the data goes downwards and the strings of information are very variable
What I'd like to do for example are
1 - Search for strings "aaa" until the next occurrence of "bbb" and delete the contents
2 - Search for strings "ccc" until the next occurrence of "ddd" and insert "#" at the start of the line for all those lines of data
3 - Search for strings "eee" until the next occurrence of "fff" and insert "##" at the start of all those lines of data
At the end of this I could open the file in excel as delimited by "#" and I`ll have at least the data in a table where I can further extract useful information
Can somebody please give a pointer as to how I can go about doing this with notepad ++ (which plugins Id need to install etc)
I dont have any formal programming skills, but Im very computer savvy and Im an expert with excel.
If there are plugins that help accomplish this visually rather than via command line Id prefer that, if not I`ll use whatever other means are available
Cheers
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know exactly how to solve your problem but I know if you go to find/replace and select regular expressions you will be able to do what you are planning to do. do a search for regular expressions.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm terribly sorry because I don't regularly look for the Script forum :-(( So, I quite sure that you could manage your problems,from this time, by other means ! Anyway, I give you a very very late answer, just for additional information !
As Piccolo said in his post, it's easy enough to achieve what you want to, with simple regular expressions :-)
So :
Open the Replace dialog ( CTRL + H )
Check the Regular expression search mode ( IMPORTANT )
If necessary, uncheck the . matches newline option ( IMPORTANT )
If necessary, check the Wrap around option
However, for your FIRST case, I don't know if you want :
To delete all, between the first string aaa and the first string bbb of the line ( Case 1A )
To delete all, between the first string aaa and the last string bbb of the line ( Case 1B )
To delete all the contents of the line, included the End of Line characters ( Case 1C )
So :
For case 1A => SEARCH aaa.*?bbb and leave the REPLACE zone EMPTY
For case 1B => SEARCH aaa.*bbb and leave the REPLACE zone EMPTY
For case 1C => SEARCH .*aaa.*bbb.*\R and leave the REPLACE zone EMPTY
For case 2 => SEARCH .*ccc.*ddd.* and REPLACE #$0
For case 3 => SEARCH .*eee.*fff.* and REPLACE ##$0
And, finally, click on the Replace All button
Et voilà !
NOTE : The $0 form represents the totality of the searched string
Best Regards,
guy038
Last edit: THEVENOT Guy 2014-11-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone
I am a new user to Notepad++ (literally just installed the program) and would like to know if it supports advanced scripting like modifying data in a txt file
The problem I have is I need to sort and extract data from text files (reports) that are formatted for legibility rather than being delimited, so the data goes downwards and the strings of information are very variable
What I'd like to do for example are
1 - Search for strings "aaa" until the next occurrence of "bbb" and delete the contents
2 - Search for strings "ccc" until the next occurrence of "ddd" and insert "#" at the start of the line for all those lines of data
3 - Search for strings "eee" until the next occurrence of "fff" and insert "##" at the start of all those lines of data
At the end of this I could open the file in excel as delimited by "#" and I`ll have at least the data in a table where I can further extract useful information
Can somebody please give a pointer as to how I can go about doing this with notepad ++ (which plugins I
d need to install etc) I dont have any formal programming skills, but I
m very computer savvy and Im an expert with excel. If there are plugins that help accomplish this visually rather than via command line I
d prefer that, if not I`ll use whatever other means are availableCheers
I don't know exactly how to solve your problem but I know if you go to find/replace and select regular expressions you will be able to do what you are planning to do. do a search for regular expressions.
Hello Rhadamanthys76,
I'm terribly sorry because I don't regularly look for the Script forum :-(( So, I quite sure that you could manage your problems,from this time, by other means ! Anyway, I give you a very very late answer, just for additional information !
As Piccolo said in his post, it's easy enough to achieve what you want to, with simple regular expressions :-)
So :
Open the Replace dialog ( CTRL + H )
Check the Regular expression search mode ( IMPORTANT )
If necessary, uncheck the . matches newline option ( IMPORTANT )
If necessary, check the Wrap around option
However, for your FIRST case, I don't know if you want :
To delete all, between the first string aaa and the first string bbb of the line ( Case 1A )
To delete all, between the first string aaa and the last string bbb of the line ( Case 1B )
To delete all the contents of the line, included the End of Line characters ( Case 1C )
So :
For case 1A => SEARCH
aaa.*?bbb
and leave the REPLACE zone EMPTYFor case 1B => SEARCH
aaa.*bbb
and leave the REPLACE zone EMPTYFor case 1C => SEARCH
.*aaa.*bbb.*\R
and leave the REPLACE zone EMPTYFor case 2 => SEARCH
.*ccc.*ddd.*
and REPLACE#$0
For case 3 => SEARCH
.*eee.*fff.*
and REPLACE##$0
And, finally, click on the Replace All button
Et voilà !
NOTE : The
$0
form represents the totality of the searched stringBest Regards,
guy038
Last edit: THEVENOT Guy 2014-11-04