Join Lines using Notepad++ , VBA, MS-ACCESS:

Tony
Tony used Ask the Experts™
on
Join Lines using Notepad++ , VBA, MS-ACCESS:

Hi,
Using Ms-Access and VBA and need to:

1. Open a specific file with Notepad++  
2. Join the Lines of the text (Control + J)
3. Save and Close.

All this, just using a command from ms-Access (a command in a form, for example).
If there is a different way of doing this, even in access table, is ok. (The goal of this is Join the lines of a txt file due to the file will be used for another application for importation purposes. )  

Thank you.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
See sample of txt file.

Author

Commented:
See attached sample of txt file that needs to be "Join Lines".  This is just an example.  The reality: thousands of records.
Lee W, MVPTechnology and Business Process Advisor
Most Valuable Expert 2013

Commented:
What sample?  Why bother using notepad++, just use VBA...?
John TsioumprisSoftware & Systems Engineer

Commented:
No need for Automatic Notepad++ for such functionality...just  a simple button on your form e.g.CommandConcatenate
Private Sub CommandConcatenate_Click()
Dim myFile As String, myText As String, textline As String
myFile = PathTo_YourTextFile ' e.g."C:\Temp\Strings.txt"

Open myFile For Input As #1

Do Until EOF(1)
    Line Input #1, textline
    myText = myText & textline
Loop
Close #1
'Now myText has the lines concatenated....
End Sub

Open in new window

Top Expert 2014

Commented:
The reality: thousands of records
Thousands isn't usually considered a lot of records/lines.  You could read the entire contents of your file into a string variable and accomplish the same thing with a single Replace() function invocation.
John TsioumprisSoftware & Systems Engineer

Commented:
I missed the thousands records...would you mind giving some info about how you want the concatenated lines handled?
Distinguished Expert 2017

Commented:
I've never done this from the perspective of taking multiple records and making a single record.  What should be used as the delimiter?  I have done this the other way.  I have received files from external applications that did NOT use standard DOS rules on separating records using CrLf.  Instead, they used some predefined delimiter.  So I read the entire file as a single record and then parsed the record using the delimiter and from one humongous record created several hundred thousand standard CSV records.  The whole point of that description was that huge numbers of records can be handled in this way.  It is simply a function of how much free memory is available.

Author

Commented:
Hi Mr. John Tsioumpris.

Thanks for you reply.

I put in place his procedure, but I am not seeing the output file.

Please find attached:
PRODUCTS.TXT   (The original file).
PRODUCTS_SINGLE_LINE.TXT   (The file modified in Notepad++ using the option of Join Lines (Control + J).

Please check.

Thank you.
PRODUCTS.TXT
PRODUCTS_SINGLE_LINE.TXT
Top Expert 2014

Commented:
Your products.txt file has some text before the VELCRO 3/4" line, missing from the products_single_line.txt file.

What are you trying to accomplish by removing the end-of-line characters?

Author

Commented:
aikimark:

Hi... just ignore that first line.
I am attaching PRODUCTS.TXT again.
PRODUCTS.TXT

Author

Commented:
What are you trying to accomplish by removing the end-of-line characters?

It is because the DOS based program where the information will be imported required the data so, in just one line.

Author

Commented:
Any update on possible solutions?

Author

Commented:
Mr.
John Tsioumpris... I send the files..please check.
John TsioumprisSoftware & Systems Engineer

Commented:
Hi Tony ... i haven't produced an output file...the resulted concatenated string is stored in the myText variable.
I will make a small tweak to write the variable to a file
Software & Systems Engineer
Commented:
Here it is...check the attachment
Join.accdb

Author

Commented:
Thank you very much Mr. John Tsioumpris.  This is exactly what I needed.  
Thanks for sharing your knowledge.!!!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial