Download file and decoding its contents from FTP server to iOS application - ios

I am new to use of ftp servers. Hence please be patient and if you have any suggestion please advice.
My problem is that I have to download files from FTP server to my ios application cache all in background thread and then decode it for its contents to display the data under several heads on the UI.
Now for this I understood that https://github.com/nkreipke/FTPManager provides me proper way of downloading file. Now my problem is that the file saved in server are in csv or xls format. How do I read contents for it? Is the data downloaded as a file in my ios app in a particular format which I then need to parse for contents. Basically, I don't have to display the file as is, but read its contents and then break them under several heads and display it on UI as various different parameters. Kindly throw any light on how to approach it. Any well written parsers for this case are welcome for learning purpose. Thanks!

Normally, contents downloaded from a server are in NSData format. If you already know that the content will be a data that can be converted to string, you can use
NSString *myCSVContents = [[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding];
to convert your downloaded contents to NSString and/or use
https://github.com/davedelong/CHCSVParser
to parse the CSV contents easily.
PS: This is a CSV example, but you can do the same with xls contents the same way using a proper parser library.
https://github.com/QuetzalMX/QuetzalXLSReader

Related

Swift: How to zip multiple NSData objects for further transfer (Airdrop, Email, Dropbox...)

In my iOS Swift application I have images stored as NSData in a Realm database. Now I want to combine these images (or a subset query of them) into a single ZIP file and make it available for further transfer via Airdrop, Email and so on.
I am fine with how to transfer and how to get them out of the database but I have no clue how to create a single ZIP file out of a bunch of NSData objects.
After changing some keywords in Google for the search, I found 2 interesting looking Libs/Frameworks I now will start investigating in.
ZIP from Marmelroy
and
ZipArchive
Both can be found on GitHub. I have no big experiences with both of them at the moment. But ZipArchiveseems to have options for NSDataSupport as this is already stated in the Readme
Zip-up NSData instances. (with a filename)
So this might be an indicator for me.
You could simply serialize and archive your images instead before AirDrop sharing. See AirDropSample.

xlsx to plist in Spanish - accented characters being lost

I have been using "Plist Converter" to get my data from csv files (excel spreadsheets saved as csv files) into plists up to now and have never had any issues with it.
However, I am currently working on an app where the data I need to convert is in Spanish.
The conversion obviously still works but I lose all of the accented characters during the process. It looks like maybe some are just lost, some are changed to other accents/characters, and the majority are replaced with an upside down question mark that does not appear on the screen but I can see it in the source code.
Anyone help me get around this with plist converter, or recommend another utility?
iMac, Excel for mac, plist converter, xcode... that is what I'm using.
Thanks
Look at libxls on SouceForge - it comes with a utility to take a .xls file and create a .csv one that you can further process using command line tools. But it has no support for .xlsx.

how to convert xls to csv using IOS library?

I need to read xls files in my IOS app. First of all, I want to convert xls files to csv format files, then my app parse csv files, but I can't find any ios library to convert xls to csv, please help me
If you have a .xls file, you can use the open source DHlibxls library to read the file into your app. This is an ObjectiveC framework that wraps a C-based library. The library is quite mature.
ios or any objecive-framework doesn't provide any thing for accesseing Microsoft's xls :(
To convert-xls to/fro csv is itself a project in it!!!
On top of this, there are different format of xls, now xlsx files. And writing a xls and reading it back in proper way is tooooo-cumbursome task to accomplish. However we have managed to read it but it is not 100% efficient :(
I guess in near future you may want to move to xlsx file then your task will be a lot more difficult. You can check yourself, change the file name extension to .zip and unzip you will see many files, one having row numbers, another columns, third with links, fourth with contents and so on. Mapping and getting in correct form in not impossible but needs a lot of work.
There can be many other ways to do, I can suggest to use java api to do, or even save you xls to csv directory from excel, then your work will be easy.

Export data to XLS (not via CSV) on iOS

I need to export some data to an .XLS file, pdf, and print.
I already tried the simple solution: exporting it to .CSV with CHCSVWriter. It works for printing and saving it to pdf (I open the CSV in a UIWebView and get the PDF or print from there). However, to use the CSV to be open in excel has two main problems:
1 - First, as the name says, in the CSV the values are separated by commas, and in some versions of Excel, it requires the user to separate 'manually' in cells.
2 - I have hebrew characters, and I already tried all the string encodings, and can't have both hebrew and latin characters.
So, after giving up after days of trying to use CSV to solve the issues above, I gave up. How can I export my data to XLS?
The LibXL library provides this functionality for both xls and xlsx formats. There is no iOS version, but people say the iOS version is coming. You may want to contact LibXL support to confirm this.
EDIT:
The iOS version is available now.
This article explains how to programmatically create an Excel (.xls) file without using any external library. It just opens a file stream and it writes XML contents straight to it.
It is written in C#, but the core information coming out of it is the XML formatting used to create nodes and fill attributes for corresponding cell values and formatting.
Please consider I have not tried this myself, I found it while doing a search. Please feel free to ask if some C# bits are not clear. HTH

To retrieve the contents of .doc files?

I am working as a Software developer for Mobile Applications. I am developing an application in which i want to retrieve the contents of the .doc files that arrive on the Blackberry mobile as an Email Attachment Part. Whenever i am retrieving the contents of the .txt files, the code written for the mobile is retrieving the accurate contents but in case of .doc files, it is displaying a lot of junk material in the header and footer of the actual contents.
So, my problem is that how can i get rid of this additional junk material as i want to retrieve only the actual contents of the .doc files. Please reply
Thanks
You can get the specifications of the doc-Format from Microsoft. Though, I don't know if they're complete or even useful. Another guess would be to have a look at Projects which have implemented it, like OpenOffice.org.
Bobby

Resources