Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open, find and replace in notepad++ using VBA script

Status
Not open for further replies.

KechWins

IS-IT--Management
Aug 18, 2010
3
NG
Good day all,

Please could you help me.
I need to open a .CSV file in notepad++ using a dialogue box and then find and replace text.
Please how do I go about all these.

Thanks
 


I would IMPORT the .csv into Excel, perform the replacements and then Save.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thats the issue, I can't do that because it is being imported into a unix server so i need to work on notepad for this
 


You would be IMPORTING a text file and SAVING a text file. What's worng with that?

Instead of doing some klunky code to porcess in another application, you would be using an application that would be much simpler to manipulate.

The end result would be identical!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
KechWins,

If you don't want to import the text file into Excel to work with, then VBA probably isn't the code you want to use anyway. You'd be better off using something else, possibly php or C++ perhaps? Of course, you'll have to know one of those to use them. I know I don't know nor remember enough to carry out something like that myself. I do think those languages would be great for it if you know either.

If you want to go the VBA route, DEFINITELY import to Excel. You'll have a lot more options with a lot less required work.
 
Come to think of it, php may not be best here either... you might would end up being better off (with php) to import it to a SQL table (whatever flavor is handy, probably most likely to be MySQL, SQLLite, or maybe PostGSQL or however it's called..)

Any C language should do quite well IF you know how to code in it.
 


Perhaps the obvious has not been stated.

VBA is Visual Basic for APPLICATIONS. The APPLICATIONS are the MS Office suite of applications. So pick one to write your procedure.

I'd pick Excel, just my bias.

You could:

1) IMPORT into Excel, make the text replacaments and SaveAs a .csv: by far the simplest.

2) Write simple text file OPEN/INPUT/PRINT#/CLOSE process.

3) Use the FileSystemObject to open a text and process

This is all done in the MS Office Application.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks all for your comments. I thought so too.
Trying to find out if the modifications is done on excel if it would work.
 


"...if it woudl work."

TEXT in from file.

TEXT out to SAME file (or to another if necessary).

Pretty simple!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
TEXT innnnn
TEXT ouuuuut

WAX onnnnnn
WAX offfff

God work, danielson. ;)
 

Mr Meogie? Back to the [fuchsia]WHAT?[/fuchsia]

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
You can import into Access also, and use either find and replace or sql update queries. Depending on what you are finding and replacing queries could provide some nice options.
And then export back out as a csv.
 
Speaking of queries, if this is a one off, then you could easily just import it into SQL Server (assuming you have one - if not, then ignore this option), and use it's power to do the number crunching in a query, or series of queries, for you.

Access and Excel both give good options for handling the data, and I do believe you can run queries within Excel as well, using MS Query. Access might be easier on that front - well, it would be for me, based on my usage.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top