Documentation for pp_lib

Generated by IDLdoc

./

read_csv_pp.pro


top source read_csv_pp

result = read_csv_pp(filename, header=header [, _ref_extra=_ref_extra] [, field_names=strarr(nfields)] [, blank=blank])

A simple wrapper for read_csv_pp_strings, to assign field names based on either the file's column headers, or a user-supplied string array. It uses read_csv_pp_strings, instead of IDL's read_csv, due to its superior handling of columns types.

Return value

A structure of arrays, where each field corresponds to a column read from the input file.

Parameters

filename in required type=string

The name of the CSV file to read.

Keywords

header
_ref_extra in out optional

Any other arguments are simply passed to/from read_csv_pp_strings, unaltered.

field_names in optional type=strarr(nfields)

A string array with the name to assign to each field (column) in the output. If provided, this overrides the auto column names derived from the csv header line.

blank in optional default=0

If set, blank (empty / whitespace) strings are allowed in numeric columns: if a column contains numbers and blank values, its type will be numeric, and any blanks will be replaced with 0. When not set (default), a column containing blanks will be returned as strings. Note that, due to the way the original read_csv operates, a colum consisting entirely of blanks will be returned a string column.

Examples

To read IDL's example csv file:

c=read_csv_pp(file_which('ScatterplotData.csv'),n_table_header=1,header=h) help,c ;** Structure <ec157fb8>, 3 tags, length=3080, data length=3080, refs=1: ;DISTANCE_FROM_TERMINUS__METERS_ LONG Array[154] ;MEAN_PARTICLE_SIZE__MM_ DOUBLE Array[154] ;SEDIMENTATION_RATE__G_CM2YR_ DOUBLE Array[154] ;print,h ;Distance from Terminus (meters) Mean Particle size (mm) Sedimentation Rate (g/cm2yr)

Author information

Author:

Paulo Penteado (http://www.ppenteado.net), Feb/2013

Other attributes

Requires:

pp_isnumber, read_csv_pp_strings

Statistics

Lines:
28 lines
McCabe complexity:
6

File attributes

Modification date: Mon Sep 22 09:38:55 2014
Lines: 77
Docformat: rst rst