CSwiftV icon indicating copy to clipboard operation
CSwiftV copied to clipboard

improve docs

Open Daniel1of1 opened this issue 8 years ago • 4 comments

Daniel1of1 avatar May 10 '16 20:05 Daniel1of1

Hey, thanks for this. Can you add something to the doc like: what if I need to read from a csv file ? should I read it line by line using swift string methods then call that string using CSwiftV(String: inputString) ? or should I use something else ?

Sorry for this question but I'm new to programming and have no idea how to use your framework to read from a csv file

sohaeb avatar Jul 28 '16 00:07 sohaeb

Thanks for the comment that's really useful. This will go in.

For now, for your particular question, the library works on a single string. So if you want to read from a file, you would do something along the lines of:

let inputString = try! String(contentsOfFile: "path/to/file")

let csv = CSwiftV(String: inputString)

Then on csv you can ask for .rows or .keyedRows which will give you either an 'array' of rows (and a row is an array of strings) or an array of 'keyedRows' which are dictionaries of type [String:String] which have the header of the column as their key.

Daniel1of1 avatar Aug 06 '16 22:08 Daniel1of1

One thing that could be added to the doc is - how do I include this in my project? I tried building it and dragging the .framework over to another project's Frameworks, but it didn't work. I eventually got it to work with CocoaPods, though I had to manually update the out-of-date code it downloaded to replace it with Swift 3-compatible code

thully avatar Oct 03 '16 22:10 thully

Nice @thully thanks, check out my comment for the other issue by the way incase it helps in any way. https://github.com/Daniel1of1/CSwiftV/issues/29#issuecomment-251667487

Daniel1of1 avatar Oct 05 '16 13:10 Daniel1of1