Comments (17)
Framework only supports array of JSON string and NSDictionary. Like below.
let string = "[{\"a\":1,\"b\":2,\"c\":3},{\"a\":4,\"b\":5,\"c\":6}]";
let filePath:String = exportCSV("userlist", fields:["a","b","c"], values:string);
print(filePath)
let fileDetails = readCSV(filePath);
if fileDetails.allKeys.count > 0 {
print(fileDetails)
}
// First Row Object
let row1:NSMutableDictionary = NSMutableDictionary()
row1.setValue(1, forKey: "a" );
row1.setValue(2, forKey: "b" );
row1.setValue(3, forKey: "c" );
// Secound Row Object
let row2:NSMutableDictionary = NSMutableDictionary()
row2.setValue(4, forKey: "a" );
row2.setValue(5, forKey: "b" );
row2.setValue(6, forKey: "c" );
// 3rd Row Object
let row3:NSMutableDictionary = NSMutableDictionary()
row3.setValue(7, forKey: "a" );
row3.setValue(8, forKey: "b" );
row3.setValue(9, forKey: "c" );
// Add dictionary into rows of CSV Array
let data:NSMutableArray = NSMutableArray()
data.add(row1);
data.add(row2);
data.add(row3);
let path:String = SwiftCSVExport.exportCSV("numberList",fields: ["a", "b","c"],values: data);
print(path)
let numberDetails = readCSV(path);
if numberDetails.allKeys.count > 0 {
print(numberDetails)
}
Sorry, You can use as like below as of now. I will do fix accordingly.
let numberArray = [["a": 1, "b": 2, "c": 3],
["a": 4, "b": 5, "c": 6],
["a": 7, "b": 8, "c": 9]]
// Add dictionary into rows of CSV Array
let data:NSMutableArray = NSMutableArray()
let fields = ["a", "b","c"];
for dict in numberArray {
let row:NSMutableDictionary = NSMutableDictionary()
for i in 0 ..< fields.count {
row.setValue(dict[fields[i]], forKey: fields[i] );
}
data.add(row)
}
let path:String = SwiftCSVExport.exportCSV("numberList",fields: fields,values: data);
print(path)
let numberDetails = readCSV(path);
if numberDetails.allKeys.count > 0 {
print(numberDetails)
}
from swiftcsvexport.
Cool. Thanks.
from swiftcsvexport.
Try with SwiftCSVExport (1.0.2)
from swiftcsvexport.
First | Last | Company | Address1 | Address2 | City | State | Postalcode | Country | Sender | Frontimage | Backtext | Accentimage | Backimage | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Loma Linda | Back Image | Back Text | 2nd Floor | Mary Ann | Missouri | 64804 | Fuller | 4 States Printing | Accent Image | Record ID | Rusty | 12345678 | Front Image | United States | 1234 Appaloosa Way |
I'm getting strange formatting
from swiftcsvexport.
New version 1.0.4 released.
Release Note: https://github.com/vigneshuvi/SwiftCSVExport/releases/tag/1.0.4
from swiftcsvexport.
from swiftcsvexport.
I will look into your code again and let you know.
Can you please provide your "Backtext" string?
from swiftcsvexport.
Hi @kedolg ,
You have used wrong field key to generate CSV file.
user1.setObject("Back Text", forKey: "BackText" as NSCopying); //optional
let filePath:String = SwiftCSVExport.exportCSV("userlist1",fields: ["DMID", "RecordID", "First", "Last", "Company","Address1", "Address2", "City", "State", "Postalcode", "Country", "Sender","Frontimage", "Backtext", "Accentimage","Backimage"],values: data);
"BackText" or "Backtext" ?
Note: Please maintain consistency between keys which you used in Dictionary and Field Array.
from swiftcsvexport.
from swiftcsvexport.
@kedolg ,
Will work on punctuation staff and will release new build.
As of now, I have replaced "\n", "\t" and "\r" with empty string.
from swiftcsvexport.
from swiftcsvexport.
@kedolg ,
I have handled the punctuation too! I will release version 1.0.5 by tomorrow.
Enjoy with my framework!
I'm from India, Tamil-nadu and my profile.
from swiftcsvexport.
from swiftcsvexport.
Hi @kedolg & @DogandElk
🚀 SwiftCSVExport (1.0.5) successfully published
📅 November 7th, 21:07
🌎 https://cocoapods.org/pods/SwiftCSVExport
iCloud is big staff. We have to configure in developers account and so on!
from swiftcsvexport.
from swiftcsvexport.
@DogandElk ,
Have you changed Podfile as like below?
pod 'SwiftCSVExport', :git => 'https://github.com/vigneshuvi/SwiftCSVExport.git', :tag => '1.0.4'
into
pod 'SwiftCSVExport'
from swiftcsvexport.
from swiftcsvexport.
Related Issues (20)
- Row values without quotes don't import correctly. HOT 1
- Row with same values as fields won't be imported HOT 7
- Cant use in Objective C Project HOT 1
- No flexible enough HOT 2
- How to handle comma in address ? HOT 2
- Won't build with Xcode 10.2 - Swift 3.0 HOT 1
- Support chinese language HOT 5
- How can I install and import SwiftCSVExport to macOS project? HOT 3
- How can i add multiple tables(with different structures) in 1 csv file? HOT 9
- Adding Two Spaces HOT 1
- Issues with attributes of class CSV HOT 1
- SwiftPM in Xcode 12: Failed to resolve dependencies. HOT 5
- Cannot find 'exportCSV' in scope HOT 3
- Quotes in string HOT 4
- How to make header as vertical and values as side by side
- Change cell properties
- Support Turkish Characters
- CSV Export Merging Rows for different Data Set
- Commas in text strings act as delimiters and cause the generated CSV file to have content that gets shifted to the next column HOT 8
- String quotes HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftcsvexport.