how to store data from a pdf file to sqlite for using in iPhone programmimng - iphone

I am having a pdf file contaning quotes of some famous people.I want to store these quotes in sqlite database.any suggestions?

There is no direct relation with pdf and sqlite.
First you have to somehow decode the information/data from pdf file. Read the quotes in text format.
Then you can insert them in a sqlite database.
Its a kind of tough job to decode information from pdf file. Then you need to know the structure of the pdf file format. You can get a description here pdf file format
I think you can look for some pdf file converter to convert it into text, html, xml or csv. Then read that by your app.

I think best way is through command line
awk '{printf"INSERT INTO Quotes VALUES (\x27%s\x27,\x27 Abraham Lincon\x27);\n",$0}' Quotes-AbrahamLincon.txt
where Quotes-AbrahamLincon.txt contains
A friend is one who has the same enemies as you have.
A house divided against itself cannot stand.
A woman is the only thing I am afraid of that I know will not hurt me.
output will be
INSERT INTO Quotes VALUES ('A friend is one who has the same enemies as you have.',' Abraham Lincon');
INSERT INTO Quotes VALUES ('A house divided against itself cannot stand.',' Abraham Lincon');
INSERT INTO Quotes VALUES ('A woman is the only thing I am afraid of that I know will not hurt me.',' Abraham Lincon');
now you can write this into sqlite db

Related

How to programatically get the fragments called in an RTFtemplate?

I need to programmatically find the fragments that are called by each rtftemplate.
So, for example in the figure, I would need to get the "GlossaryTermsAcronyms" fragment for the H2_terms_acronyms template.
I can't seem to find any query or script solution to do this. But this should be possible, right?
Unfortunately that is (almost) impossible.
The information is stored in the t_documents.bincontent column. It is binary encoded RTF.
Somewhere in that RTF there should be a reference to the templates fragments that are used.
If you can figure out how to decode the bincontent to get to the actual RTF code of your template, you might have a chance.
Binary fields in EA are usually stored as a zipped text file.
In case the field is included in an xml file (or xml string in the database), it will be base64 encoded.

PostgreSQL Escape Microsoft Special Characters In Select Query

PostgreSQL, DBvisualizer and Salesforce
I'm selecting records from a database table and exporting them to a csv file: comma-separated and UTF8 encoded. I send the file to a user who is uploading the data into Saleforce. I do not know Salesforce, so I'm totally ignorant on that side of this. She is reporting that some data in the file is showing up as gibberish (non UTF8) characters (see below).
It seems that some of our users are copy/pasting emails into a web form which then inserts them into our db. Dates from the email headers (I believe) are the text that are showing as gibberish.
11‎/‎17‎/‎2015‎ ‎7‎:‎26‎:‎26‎ ‎AM
becomes
‎11‎/‎16‎/‎2015‎ ‎07‎:‎26‎:‎26‎ ‎AM
The text in the db field looks normal. It's when it is exported to a csv file and then that file is viewed in a text-editor like Wordpad or Salesforce. Then she sees the odd characters.
This only happens with dates from the text that is copy/pasted into the form/db. I have no idea how, or if there is a way, remove these "unseen" characters.
It's the same three-characters each time: ‎ I did a regex_replace() on these to strip them out, but it doesn't work. I think since they are not seen in the db field, the regex does see them.
It seems like even though I cannot see these characters, they must be there in some form that is making them show in text-editors like Wordpad or the Salesforce client after being exported to csv.
I can probably do a mass search/find/replace in the text editor, but it would be nice to do this in the sql and avoid the extra step each time.
Hoping someone has seen this and knows an easy fix.
Thanks for any ideas or pointers that may help.
The sequence ‎ is a left-to-right mark, encoded in UTF-8 (as 0xE2 0x80 0x8E), but being read as if it were in Windows-1252.
A left-to-right mark is invisible, so the fact that you can't see it in the database suggests that it's encoded correctly, but without knowing precisely what path the data took after that, it's hard to guess exactly where it was misinterpreted.
In any case, you should be able to replace the character in your Postgres query by using its Unicode escape sequence: E'\u200E'

convert html to text or formatted text from an iphone 4 notes backup sqlite file

I wanted to restore some of the lost notes that I obtained by using an iTunes backup (of an iphone 4) and opening up the notes.sqlite file. When I query the table that contains the notes text:
select zcontent from znotebody
I get the text that is in html format. How can I convert those entries to a more readable content? It doesnt have to be perfect, just enough to be able to read it. Here is an example of a note:
Meds fir odd<div>Trazadone</div><div>Effexor (& Cd)</div><div>Buspirone</div><div>Clonodine</div><div>Nortriptyline</div><div>Risperdal</div><div>Straterra </div>
Here is the actual note from above:
Meds fir odd
Trazadone
(Effexor & Cd)
Buspirone
Nortriptyline
Risperdal
Straterra<space here>
If you just want to retrieve the note text, I would try this
select "" + zcontent + ""
from znotebody
Then save to a file and open in browser
You have to look some NSString categories, to escape html tags in your text.
Follow this link will help to solve the issue.. Objective C HTML escape/unescape

Characters in DB displaying strangely

I'm creating a trivia iPhone app. I've written 1,000 questions or so in the mac app Numbers. The problem I'm having is that when I export the document to a CSV then open it in mySQL lite and save it as a database for the app, things like apostrophes turn out strangely for example "there's" would turn out as thereás instead. Is there any easy way to correct this issue?
Thanks,
Chris
This is happening because you are generating the CSV file from a MS doc or excel file
where
if i write "There’s" in MS Doc(look the apstrophe character)
but if i write same text in a simple text file "There's" (look the changed apstrophe character)
That is why the text is displaying as thereás due to character encoding problem.
So you have to change the (’)character in to (') to display it correctly.

How would I go about parsing this .xml for iPhone table

I am making a directory for an app and I need to parse the the names, e-mail, phone #, and office for each item that I want to display in a UITableView. I have a class made but I have never really dealt with pasring anything past simple txt files.
I need to load a URL to a xml file, which consists of the following type of data at the bottom. It does not have xml tags, but it is saved as a .xml
I have read up on the NSXMLParsers, but I wasn't sure if that would be the correct way to do this or if there was an easier way.
Example of part of the .xml file below, this is just part of a few hundred lines that are organized in the same manner, by division, department, then person.
Thanks for any help!
http://cs.millersville.edu/School of Science and MathematicsDr.FirstH.LastRoddy Science CenterFirst.Last#millersville.edu872-3838Computer ScienceMrs.First.LastRoddy Science CenterFirst.Last#millersville.edu872-3858Computer ScienceDr.FirstH.LastRoddy Science CenterFirstH.LastRoddy#millersville.edu872-3470Computer ScienceDr.FirstH.LastRoddy Science CenterFirst.Last#millersville.edu872-3724Computer ScienceMs.FirstA.GilbertLast Science CenterFirst.Last#millersville.edu871-2214Computer ScienceDr.FirstH.LastRoddy Science CenterFirst.Last#millersville.edu872-3666
There's no way you can use a xml parser for this file.
Instead you may try to use NSScanner to parse the text file. A couple of tutorials are listed here:
Parsing CSV Data
Writing a parser using NSScanner
without the xml tags, your file is as good as a plain text file...
rows separated by new line character....
and each line contains data separated by a dot (.) or something like that. figure out the pattern and parse it like you would parse a text file...