Giter Site home page Giter Site logo

csvparser's People

Contributors

nero5023 avatar wangzhuo2015 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csvparser's Issues

Russian Excel problem in encoding

Hi, thanks for great library!
Have some issues:

(1) I have some problems in text encoding in Russian excel file, what can cause this issue?
(2) Also, it would be best to write some performance test, because in large files it's working slowly.

img_2017-03-13 12 23 10

Unable to install onto actual iPhone

Whenever one of my project is run with CSVParser as one of its frameworks (and even when it is the only framework used in the entire project), and run on an actual iPhone, the error "This Application's bundle identifier does not match its code signing identifier". Are there any solutions to this problem by anyone?

Not able to build on last xcode, swift 4.1

extension CSVParser: RangeReplaceableCollection {
  public func replaceSubrange<C>(_ subrange: Range<Int>, with newElements: C) where C : Collection, C.Iterator.Element == Array<String> {
    self._rows.replaceSubrange(subrange, with: newElements)
  }
  public func reserveCapacity(_ n: Int) {
    self._rows.reserveCapacity(n)
  }
}

Here i have got error.

iOS target version not set in project

Could you set an explicit iOS target version to something like 8.0 9.0 for backwards compatibility, because while building with Carthage it assumes its latest version which does not allow for backwards compatibility at least 1 or ideally two versions back like 9 or 8.

Thanks!

Crash on Linux

I got an error when running an app on Ubuntu.

Fatal error: init(contentsOfFile:usedEncoding:) is not yet implemented: file Foundation/NSString.swift, line 1308

It's caused by this line

public convenience init(filePath: String, delimiter: Character = ",", lineSeparator: Character = "\n") throws {
    let fileContent = try String(contentsOfFile: filePath) // <-- this line
    try self.init(content: fileContent, delimiter: delimiter, lineSeparator: lineSeparator)
  }

You should consider to use the same method with explicit encoding.
Following code works well on Ubuntu:

let fileContent = try String(contentsOfFile: filePath, encoding: .utf8)

Can't form a Character from an empty String

Hi there!

I'm trying to initialize a CSVParser from a String and I'm getting a fatal error.

Line 29 of parser.swift is if inputContents[cursor] == quotes {

This line is throwing fatal error: Can't form a Character from an empty String

inputContents[cursor] and quotes are both equal to a single " and I've tried several things trying to debug this but got nowhere.

This is the string I'm passing to the initializer with let csvParser = try CSVParser(content: csvString) is:

"Subject 1 #hashtagone","http://example.com/one"
"Subject 2 #hashtagtwo","http://example.com/two"
"Subject 3 #hashtagthree","http://example.com/three"

Any ideas?

Headers property?

It would be nice to be able to have headers parsed separately from rows(if the file has headers) so you could do something like let csv = CSVParser(content: string, hasHeaders: true) and then be able to let headers = csv.headers and let rows = csv.rows

Cannot assign through subscript: subscript is get-only after swift 4.1

When i try to Write data

let csv = try CSVParser(filePath: "path/to/csvfile")
// get every row in csv

    below line throws an error after updating to 4.1
csv[0] = ["test0", "test1", "test2"]  //  **Cannot assign through subscript: subscript is get-only**

csv.wirite(toFilePath: "path/to/destination/file")

";" delimiter... crash ?

Hi !

So, excel being excel, it exports utf-8 csv using semi-columns (;) characters as delimiters, and \r as line separators.

So I specified those as such... and running crashes the program in Xcode, hitting a breakpoint in the CFHash thread, before stopping with

Message from debugger: Terminated due to signal 9

I don't have any breakpoint in my code, and CSVParser is the only framework I'm using.
Any idea ?

Just in case, here's my function

    func importCSV(filePath: String) {
	do {
		let delimeter: Character = ";"
		let lineSeparator: Character = "\r"
		let csv = try CSVParser(filePath: filePath, delimiter: delimeter, lineSeparator: lineSeparator)
		var i = 0
		for row in csv {
			print("Row \(i): \(row)\n") // ["first column", "sceond column", "third column"]
			i += 1
		}
		do {
			let jsonStr = try csv.toJSON()
			consoleIO.writeMessage("json: \(jsonStr)")
		} catch let csvToJsonError {
			consoleIO.writeMessage(csvToJsonError.localizedDescription, to: .error)
		}
	} catch let error {
		print(error)
		consoleIO.writeMessage(error.localizedDescription, to: .error)
	}
    }

Using a random character as delimiter (such as "j") makes it work just fine... almost.

csv.toJSON() fails on the enumeratedWithDic() function, but I guess it's because there aren't any headers (since "j" isn't really a delimiter in the csv file ^^")

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.