All Projects → Nero5023 → Csvparser

Nero5023 / Csvparser

Licence: mit
A swift package for read and write CSV file

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Csvparser

csvlixir
A CSV reading/writing application for Elixir.
Stars: ✭ 32 (-56.16%)
Mutual labels:  csv-parser
Awesomecsv
🕶️A curated list of awesome tools for dealing with CSV.
Stars: ✭ 305 (+317.81%)
Mutual labels:  csv-parser
Clevercsv
CleverCSV is a Python package for handling messy CSV files. It provides a drop-in replacement for the builtin CSV module with improved dialect detection, and comes with a handy command line application for working with CSV files.
Stars: ✭ 887 (+1115.07%)
Mutual labels:  csv-parser
csvtogs
Take a CSV file and create a Google Spreadsheet with the contents
Stars: ✭ 15 (-79.45%)
Mutual labels:  csv-parser
Pygeno
Personalized Genomics and Proteomics. Main diet: Ensembl, side dishes: SNPs
Stars: ✭ 261 (+257.53%)
Mutual labels:  csv-parser
Jsoncons
A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
Stars: ✭ 400 (+447.95%)
Mutual labels:  csv-parser
lazycsv
A fast, lightweight and single-header c++ csv parser library
Stars: ✭ 53 (-27.4%)
Mutual labels:  csv-parser
Csv
Fast C# CSV parser
Stars: ✭ 53 (-27.4%)
Mutual labels:  csv-parser
Rapidcsv
C++ CSV parser library
Stars: ✭ 261 (+257.53%)
Mutual labels:  csv-parser
Filehelpers
The FileHelpers are a free and easy to use .NET library to read/write data from fixed length or delimited records in files, strings or streams
Stars: ✭ 917 (+1156.16%)
Mutual labels:  csv-parser
CsvTextFieldParser
A simple CSV parser based on Microsoft.VisualBasic.FileIO.TextFieldParser.
Stars: ✭ 40 (-45.21%)
Mutual labels:  csv-parser
VBA-CSV-interface
The most powerful and comprehensive CSV/TSV/DSV data management library for VBA, providing parsing/writing capabilities compliant with RFC-4180 specifications and a complete set of tools for manipulating records and fields.
Stars: ✭ 24 (-67.12%)
Mutual labels:  csv-parser
Vroom
Fast reading of delimited files
Stars: ✭ 462 (+532.88%)
Mutual labels:  csv-parser
java-read-write-csv-file
Read and Write CSV files in Java using Apache Commons CSV and OpenCSV
Stars: ✭ 57 (-21.92%)
Mutual labels:  csv-parser
Fast Csv
CSV parser and formatter for node
Stars: ✭ 1,054 (+1343.84%)
Mutual labels:  csv-parser
VBA-CSV
CSV Parser and Writer as VBA functions
Stars: ✭ 26 (-64.38%)
Mutual labels:  csv-parser
Csv Parser
A modern C++ library for reading, writing, and analyzing CSV (and similar) files.
Stars: ✭ 359 (+391.78%)
Mutual labels:  csv-parser
Csv File Validator
🔧🔦 Validation of CSV file against user defined schema (returns back object with data and invalid messages)
Stars: ✭ 60 (-17.81%)
Mutual labels:  csv-parser
Faster Than Csv
Faster CSV on Python 3
Stars: ✭ 52 (-28.77%)
Mutual labels:  csv-parser
Csvutil
csvutil provides fast and idiomatic mapping between CSV and Go (golang) values.
Stars: ✭ 501 (+586.3%)
Mutual labels:  csv-parser

CSVParser

A swift library for fast read and write CSV file. This library supports all Apple platform and Linux.

Carthage compatible Plafrom

List to do


  • [x] get column by string subscript
  • [x] error
  • [x] initialization from string
  • [x] Convert JSON To CSV
  • [x] Convert CSV To JSON
  • [ ] Concurrent parse

Requirements


  • Swift 4.0+

Installation


Swift Package Manager(Support Ubuntu)

If you want to use this package on Ubuntu, you shounld install with Swift Package Manager

In Package.swift file

import PackageDescription

let package = Package(
  name: "YourProject",
  dependencies: [
    .Package(url: "https://github.com/Nero5023/CSVParser",
        majorVersion: 1),
    ]
)

Run command

$ swift build

Carthage

To integrate CSVParser into your Xcode project using Carthage, specify it in your Cartfile:

github "Nero5023/CSVParser" ~> 2.0.0

Run carthage update to build the framework and drag the built CSVParser.framework into your Xcode project.

Usage

Initialization

let csv = try CSVParser(filePath: "path/to/csvfile")

//catch error
do {
	let csv = try CSVParser(filePath: "path/to/csvfile")
}catch {
	// Error handing
}

// Custom delimiter
do {
	let csv = try CSVParser(filePath: "path/to/csvfile", delimiter: ";")
}catch {
	// Error handing
}

// init from elements
let csv = try CSVParser(elements: [["a", "b", "c"], ["1", "2", "3"]])

Read data

do {
	let csv = try CSVParser(filePath: "path/to/csvfile")
	// get every row in csv
	for row in csv {
        print(row) // ["first column", "sceond column", "third column"]
    }
    
    // get row by int subscript 
    csv[10] // the No.10 row
    
    // get column by string subscript
    csv["id"] // column with header key "id" 
	
}catch {
	// Error handing
}

Write data

do {
	let csv = try CSVParser(filePath: "path/to/csvfile")
	// get every row in csv
	csv[0] = ["test0", "test1", "test2"]
	csv.wirite(toFilePath: "path/to/destination/file")
	
}catch {
	// Error handing
}

Subscript

// get row by int subscript 
csv[10] // the No.10 row
    
// get column by string subscript
csv["id"] // column with header key "id" 

Get dictionary elements

for dic in csv.enumeratedWithDic() {
	print(dic) // dic is [String: String]	
}

CSV to JSON

The result json type is [{"header0": "a","header1": "b"},{"header0": "a", "header1": "b"}]

do {
	let jsonStr = try csv.toJSON()
}catch {
	// Error handing
} 

JSON to CSV string

Now only support this json type [{"header0": "a","header1": "b"},{"header0": "a", "header1": "b"}]

do {
	let csvString = try CSVParser.jsonToCSVString(jsonData: jsonData) // jsonData is the Data type ot json
}catch {
	// Error handing
} 

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].