Industrial Data Science
in C# and .NET:
Simple. Fast. Reliable.
 
 

ILNumerics - Technical Computing

Modern High Performance Tools for Technical

Computing and Visualization in Industry and Science

tgt

ILNumerics - Text I/O

Text / CSV

General usage

Reading from comma seperated text files is done with ILMath.csvread<T>()

Writing to csv format text files is done via ILMath.csvwrite<T>()

Visit the class reference for csvread and csvwrite.

Complex numbers

Reading complex numbers from CSV files are supported internally from version 4.8. The conversion is automatically done, reading them were never easier: 

Custom formats

It is possible to read custom formatted values, custom types from comma seperated text files with ILMath.csvread<T>(). To ensure such functionality, there is a delegate method called 'ILMath.CSVConvertElement<T>(string element, IFormatProvider culture)'.

Example

The following example demonstrates how to read custom formatted geo coordinates from a CSV file. Let say the format for each element is stored as follows: 'LATITUDE|LONGITUDE|ALTITUDE'. Where the separator is '|', and the elements are stored as double values.

 

 After the parsing method is written, just add the name of custom delegate method to the last argument of the 'csvread' method. The following code reads the CSV file, and converts every element with the help of the the custom method: