Can i keep any possible file formats in utf8 string? - encoding

I want to make a simple database where every recieved files will be stored in the same dump-file along with regular text data. I dont want to bother with storing them as uniq files in some folder on my server cos it looks very complicated. So can i convert any possible file formats (pictures, music, videos, archives etc.) into an utf8 string and just put it in a text file without any losses? Im sure i can open any file in notepad without exception but for some reason this operation is very slow and im not sure that notepad using exactly utf8 always so cant answer by myself.
I was trying to google it but seems like im the first crazy person with such an idea.

Related

Rename a group of .txt files based on content that appears after a specific string in the text file?

I have a folder with hundreds of text files in it. The file names have zero meaning. I am trying to extract a variable number that appears after a string in each file and and rename the files using it. I'm somewhat of a Powershell newbie (an old timer form the DOS world) but I have written many useful scripts with it. I've searched high an low, this one has me stumped.
Any and all suggestions are welcome, or I'd happily pay someone for the snippet of code. -Ed

load unix executable file to ascii

I am simply trying to load ascii files with two columns of data (spectral data).
They were saved originally as .asc.
I need to open and edit them using text editor before I can load them into Matlab to erase the headers, but some of them somehow got converted to unix executable foramt with the .asc extension. And others are plain text docs also with the same extension. I have no idea why they got saved with the same extension and with my same manipulation as different kind formats.
When I use the load command in Matlab, the plain text docs load normally as expected but the ones saved as unix executable kinds give me this error:
Error using load Unable to read file filename.asc: No such file or
directory.
How can I either resave them (still with the same extension) or otherwise load them to be read by Matlab as standard two column data matrixes?
Thanks!
If these are truly plain text files, try renaming the file from xxx.asc to xxx.txt. Then, see if you are able to edit them as desired.

How to append text to a file in Objective C?

I have a form in my app that the user fills out, then the app needs to write what the user entered into a .java file that is then sent to the user. Basically, I'm making a mobile Java IDE. Please help! I need to know how to append text into certain locations in the file. Excuse me if this doesn't make sense, just ask me what part is confusing, I might be able to explain it better.
You are probably a lot better off storing all your text in a database, where you can easily insert new text at any location.
Actually storing the text in a file is problematic - appending is easy, you just open the file, seek to the end, and then write new text. But you really want arbitrary insertion of text which means seeking to that point in the file, reading in the rest of the file, writing out your new data, then writing out the old remainder of the file...
If you store all the text in a database you can organize it to make it easy to insert new text, probably append some useful metadata about the text, and when the user asks to email the file simply write everything you have out to a file in temporary storage and send that (or create the text in memory and send it as NSData).

Create Numbers file and open it with Numbers on iPad

I would like to do a task that is quite simple on other OS, but it is not so trivial on iOS. Namely, I want to create file and open it in Numbers.
I can preview the file with UIDocumentInteractionController and then offer it to user that he/she opens it.
THis seems to me quite a reasonable solution. However, I need to offer proper file format. I suppose CSV and XLS would be reasonable to implement and it would most probably work, but I would still like to do it in native Numbers format if possible. However, I can't find any info about this file format.
Basically, this task is about exporting data to another app and then working further with them.
I don't know of a library that can create native Numbers files. There are hoewever some libraries that allow creating XLS files. Since Numbers fully supports XLS, this is probably the way to go.
There is a comercial library available that might work on the iPhone (costs $200): http://www.libxl.com/
As for free XLS libraries, I only know xlwt, a Python module. You could set up a webservice that creates an XLS file for your app, using xlwt on the server side.
If you want to pass information to Numbers, you can probably also use CSV files. If you use CSV files, you must be aware of some things. There are two kinds of CSV files: the comma separated version (used in english speaking countries) and the semicolon separated (used in continental europe).
The comma separated CSV files look for example like this:
"ID","First Name","Last Name","Salary"
1,"John","Malkovich",3400.20
2,"Fred","Astaire",2000.60
The second kind of CSV files are semicolon separated and use a comma as decimal mark. They look like this:
"ID";"First Name";"Last Name";"Salary"
1;"John";"Malkovich";3400,20
2;"Fred";"Astaire";2000,60
On the Macintosh, Numbers expects a different format depending on the Region setting. If you have your Region set to the US, it will expect the first kind. If you choose Germany, it will expect the second kind.
I don't know what kind of files Numbers on the iPad expects.
Another alternative would be using copy and paste. Try to copy tab separated text into the clipboard.
I hope this may help you. I've contacted libxl team and they responded with the link to the demo version of their iPhone library: http://www.libxl.com/download/libxl-iphone.zip

Create PDF from CSV on iPhone

An iPhone app which I am creating generates reports from a Core Data database as a CSV file, which can then be emailed so that the user may use that data elsewhere outside of the app. I would also like to offer the ability to generate the same reports as a PDF file (of course, with nicer formatting) allowing the user to immediately print the report rather than having to jump through several hoops as with the CSV file - i.e. open in another application (e.g. Excel, Numbers) then reformat the columns (so they are wide enough for printing), bold the headings, etc.
Essentially, I want to provide the PDF file so that the user is immediately given a nicely formatted report, and they only need to export the CSV file if they wish to do data manipulation and need a format which is editable.
I was thinking that the easiest method would be taking the CSV file and the converting this into a PDF file, which would be the same as the CSV except would incorporate nicer formatting (such as a tabular layout) rather than the simple comma-separated format of the CSV file. I have been unable to find any ready-made classes for this purpose (to avoid reinventing the wheel) and I am unsure how to approach this since I have limited experience with this aspect of the SDK. Any suggestions or pointers in the right direction would be much appreciated.
You have two different problems:
Read CSV data into some structure in memory
Turn some structure in memory into a PDF
Aaron Saunders has posted some links for step 2, so here's a link for step 1:
http://github.com/davedelong/CHCSVParser
That's a CSV parser I wrote that will turn your CSV file into an NSArray of NSArrays of NSStrings.