[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VBA: Read textfiles in Unix format

Posted on 2006-06-23
6
Medium Priority
?
1,623 Views
Last Modified: 2012-05-05
I have a huge textfile in Unix format of several megabytes that I want to read line by line. How do I do this in VBA?
Do I have to convert it to DOS/Windows format first? How?
0
Comment
Question by:IgnaceLamine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16967515
Hi,

The UNIX and DOS (and Windows) operating systems differ in the format in which they store text files.

DOS places both a carriage return character [vbCr or Chr$(13)] & a line feed character [vbLf or Chr$(10)] at the end of each line of a text file, but Unix uses only a line feed character.

Some DOS applications need to see carriage return characters at the ends of lines, and may treat Unix-format files as giant single lines.

Some Unix applications won't recognize the carriage returns added by DOS, and will display Ctrl-M characters at the end of each line (shown on-screen as ^M).


You do not have to convert UNIX text files to DOS format in order to read them, but you need to ensure that whilst reading the lines with VBA that you then replace all single vbLf characters with vbCrLf.

BFN,

fp.
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 500 total points
ID: 16967530
As example of VBA to read UNIX text files can be found here:

"Replace line-feeds with carriage return / line feed"
[ http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10444356.html ]

There is also reference to a utility you can use instead called "unix2dos".

The link in the PAQ is now offline, but searching in Google can return many similar tools, such as:
[ http://www.nichesoftware.co.nz/unix2dos.html ]


BFN,

fp.


0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17309948
Thanks (again) Dan.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question