https://github.com/gnikit/fileio
A template allowing to read multiple columns of tab or space delimited files. Similar functionality to numpy.loadtxt()
https://github.com/gnikit/fileio
cpp file-io library numpy
Last synced: 10 months ago
JSON representation
A template allowing to read multiple columns of tab or space delimited files. Similar functionality to numpy.loadtxt()
- Host: GitHub
- URL: https://github.com/gnikit/fileio
- Owner: gnikit
- Created: 2018-06-03T12:56:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-24T13:01:03.000Z (over 5 years ago)
- Last Synced: 2025-02-01T20:14:08.311Z (about 1 year ago)
- Topics: cpp, file-io, library, numpy
- Language: C++
- Homepage:
- Size: 8.48 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FileIO: Easy to use file-reading/writting template
[](https://travis-ci.com/GNikit/FileIO)
## Description
A simple header only implementation read/write template class for:
1. Writting 2D and 1D vectors in ASCII to file
2. Reading whole or partial (certain columns) ASCII files into 2D and 1D vectors
3. Displaying 2D and 1D vectors
The class offers support for writing vectors to files in by using
one of two formats:
- Row major (each vector is a row in the output file)
- Column major (each vector is a column in the output file)
Similar functionality to `numpy.loadtxt()`.
Returns a `vector>` of the read columns.
In the case where the user-defined columns *n* are less than the file columns,
`ReadFile()` will read only the first *n* columns.
## Usage
Sample code reading and writing a 2D vector
```C++
#include "FileIO.h"
int main() {
FileIO file;
// Load 2D vector from file
// args: filename, file columns, comment char, format=1:column-major
std::vector> test = file.ReadFile("example.log", 2, '#');
// Write 2D vector to file
// args: 2D vector, filename, delimiter
file.Write2File(test, "example_copy.log", " ");
}
```