Code Monkey home page Code Monkey logo

tsvtools's Introduction

TSVTools

TSVTools is a lightweight library that makes it easy to read and write TSV (tab-separated values) files in C#. It provides a simple and intuitive interface for working with TSV files, allowing you to quickly and easily read and write data in TSV format.

Installation

You can install TSVTools via NuGet using the following command:

dotnet add package TSVTools --version 1.0.4

or

NuGet\Install-Package TSVTools -Version 1.0.4

Usage

First you need write your input model:

public class MyDataModel
{
    public  string Name { get; set; }
    public  int Age { get; set; }
    public  string Email { get; set; }
}

Reading from a TSV file

To read data from a TSV file, you first need to create an instance of the TsvFile class with the path to the TSV file:

var tsvFile = new TsvFile<MyDataModel>("path.tsv");

This will create a TsvFile<MyDataModel> object that you can use to access the data in the TSV file.

Writing to a TSV file

To write data to a TSV file, you first need to create an instance of the TsvFile class with the column names for the TSV file:

var tsvFile = new TsvFile<MyDataModel>();

You can then add data to the TsvFile object by creating instances of your MyDataModel class and adding them to the TsvFile object:

var data = new MyDataModel { Name = "MHReza", Age = 18, Email = "[email protected]" }; 
tsvFile.AddRow(data);

Once you have added all your data to the TsvFile object, you can save the data to a TSV file:

tsvFile.SaveToFile("path.tsv");

This will save the data to a TSV file at the specified path.

you can read data like this:

foreach (var row in tsvFile)
{
    Console.WriteLine($"Name: {row.Name} , age is : {row.Age} , Email is {row.Email}");
}

for updating a row you use UpdateRow method

tsvFile.UpdateRow(1, new  MyDataModel {Name = "", Age = 18, Email = ""});

for get row with index you can use GetRow method

tsvFile.GetRow(1);

Appending a TSV file tp your data

To append data from a TSV file to your data, you can use the AppendFile method:

tsvFile.AppendFile("path/to/my/existing/tsv/file.tsv");

Export to a csv file

For export your data in csv file format you can use this method:

tsvFile.ExportToCsv("FilePath.csv");

Contributing

If you'd like to contribute to TSVTools, please submit a pull request or open an issue. We welcome all feedback and contributions!

tsvtools's People

Contributors

mhshahmoradi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.