Coder Social home page Coder Social logo

thcsv's Introduction

A simple CSV library for Torch

A simple CSV library for reading / writing Torch tensor objects.

Installation

From a terminal:

luarocks install thcsv

then:

thcsv = require 'thcsv'

How To Read CSV

output = thcsv.read(csvFile, [skipFirst = false])

Reads the content of file csvFile and store it into output. The output tensor will have a size of nRows x nCols. For CSV files with a header containing a list of field names, you must call the function with skipFirst = true.

How To Write CSV

thcsv.write(csvFile, input, [header = {}])

Write the content of input into file csvFile, where input is a nRows x nCols tensor. Additionally, provide a table of field names header = {id1, id2, ...} to add a header to the CSV file.

Example

thcsv = require 'thcsv'
thcsv.write('eye.csv', torch.eye(5))
output = thcsv.read('eye.csv')
output
 1  0  0  0  0
 0  1  0  0  0
 0  0  1  0  0
 0  0  0  1  0
 0  0  0  0  1
[torch.DoubleTensor of size 5x5]

thcsv's People

Contributors

ltrottier avatar

Watchers

James Cloos avatar Florient CHOUTEAU avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.