?
Solved

VBA: Read textfiles in Unix format

Posted on 2006-06-23
6
Medium Priority
?
1,564 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

771 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