No BSD License  

Highlights from
readascii

5.0

5.0 | 7 ratings Rate this file 10 Downloads (last 30 days) File Size: 8.28 KB File ID: #4068

readascii

by alex sanchez

 

19 Oct 2003 (Updated 30 Mar 2006)

Reads ascii files and prepares them for load compatibility.

| Watch this File

File Information
Description

Reads ASCII Files

USAGE:
  argout = readascii(argin)

DESCRIPTION:
  Reads an ascii file and returns (if nargout==1)
  a structure with several fields including the
  headers, text and nuemrica data.
  If the name for an out-file is given,
  the file is changed for MatLab load
  compatibility commenting all "text" lines and
  inserting NaN'. The out file may be saved as
  binary, which only saves the data of the in-file.

INPUT VARIABLE:
  argin is a structure array with fields:
      infile = file to be read
      outfile = name of out-file (only if given)
      outperm = permision for out file used for fopen.m
              examples - 'w', 'wb', 'a+', etc
              default - 'w'
      outprec = precision for out file used for fwrite.m
              examples - 'uchar', 'int8', 'single', 'double'
              default - 'uchar'
      old = text or numbers that want to be replaced
              If more than one number or text needs to be
              replaced, old may be given as a cell array
              examples - -9999, {'0000','-----'}
              default - '*****'
      new = text or number that replaces old
              default - 'NaN'

OUTPUT VARIABLE:
  argout is a structure array with the same fields as argin, plus:
      header(s) = heading of file and/or any row with characters other
              than e that are commented in an ascii out file
              any line starting with % or any non alphabet characters
      text = string data in file
      data = vector or matrix with data read from file
      flag = text indicating whether all data was read,
              if there exist rows with different
              number of columns in the in file, and
              the amount of data written to a binary file

NOTES:
  Using outfile == infile is valid but slows
  the program down considerably.
  The uigetfile dialog is invoked if nargin==0.
  Commenting a linea twice or any data linea with NaN' is avoided.
  Only permits writing to binary file if the ascii file contains
  only one data size

Copy-Left, Alejandro Sanchez

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
24 May 2005 tomy rogers

Excellent application!, very good

31 Dec 2005 Robert Odom

Thank you, it's just what I needed.

07 Feb 2006 Tom George

Great

21 Feb 2007 Vikas Kaul

Perfect! Just what I was looking for! :)

22 Aug 2007 Carlos PEREZ

Very helpful!! thanks Alex

06 Jan 2009 Shashi Kant

Super! Great work! highly appreciated.. This is the one I have been looking for !!!

11 Sep 2009 Wim

Exactly what was needed!

Please login to add a comment or rating.
Updates
11 Nov 2003

Several Improvements

13 Nov 2003

Several Improvements

18 Nov 2003

Several Improvements

15 Feb 2005

Also reads and separates texts between data

30 Mar 2006

lots of updates

Tag Activity for this File
Tag Applied By Date/Time
data import alex sanchez 22 Oct 2008 07:08:49
data export alex sanchez 22 Oct 2008 07:08:49
data alex sanchez 22 Oct 2008 07:08:50
heading alex sanchez 22 Oct 2008 07:08:50
reading alex sanchez 22 Oct 2008 07:08:50
load alex sanchez 22 Oct 2008 07:08:50
ascii alex sanchez 22 Oct 2008 07:08:50
binary alex sanchez 22 Oct 2008 07:08:50
replacing alex sanchez 22 Oct 2008 07:08:50

Contact us at files@mathworks.com