Обсуждение: loading a file into a field

Поиск
Список
Период
Сортировка

loading a file into a field

От
Brian Sherwood
Дата:
I am looking to play around with the postgres XML functions, but can't
seem to find a way to load my data.

I have a number of XML files: file1.xml, file2.xml, etc....  All files
follow the same xml format (DTD?)

I would like to create the following table:

CREATE TABLE configs  (       filename        varchar(80) PRIMARY KEY,       config  xml
);


and load each file into the xml field, but can't seem to find a way.
(I think I need something similiar to lo_import, but have not found anything)

Any help is appreciated.

Thanks


Proper case function

От
Michael Gould
Дата:
All,

Has anyone got a proper case function that they are willing to share.  We're
moving from SQL Anywhere to PostgreSQL and decided that much of our data is
upper case when it really should be proper cased.  The columns that we will
be putting proper case data in are all defined using the contrib module
citext which makes searching very nice.

Best Regards

Michael Gould




Re: Proper case function

От
Gary Chambers
Дата:
> Has anyone got a proper case function that they are willing to share.  We're
> moving from SQL Anywhere to PostgreSQL and decided that much of our data is
> upper case when it really should be proper cased.  The columns that we will
> be putting proper case data in are all defined using the contrib module
> citext which makes searching very nice.

Why doesn't the initcap function work as you require?

-- Gary Chambers

/* Nothing fancy and nothing Microsoft! */


Re: loading a file into a field

От
Tim Landscheidt
Дата:
Brian Sherwood <bdsher@gmail.com> wrote:

> I am looking to play around with the postgres XML functions, but can't
> seem to find a way to load my data.

> I have a number of XML files: file1.xml, file2.xml, etc....  All files
> follow the same xml format (DTD?)

> I would like to create the following table:

> CREATE TABLE configs  (
>         filename        varchar(80) PRIMARY KEY,
>         config  xml
> );


> and load each file into the xml field, but can't seem to find a way.
> (I think I need something similiar to lo_import, but have not found anything)

There is no function to do that in the standard distribu-
tion. You have to solve that in your client application.
Theoretically, you could try to do it in a server-side user
function, but permissions, local vs. remote file systems &
Co. usually only create major headaches.

Tim



Re: Proper case function

От
Michael Gould
Дата:
Gary,

Based on what I read it wouldn't handle cases where the result should be

MacDonald from macdonald.  There are other cases such as the sentence below

('it''s crazy! i couldn''t believe kate mcdonald, leo dicaprio, (terrence)
trent d''arby (circa the 80''s), and jada pinkett-smith all showed up to
[cHris o''donnell''s] party...donning l''oreal lIpstick! They''re heading to
o''neil''s pub later on t''nite. the_underscore_test. the-hyphen-test)

This wouldn't handle the quotes and proper case all of the words.

Best Regards

Mike Gould


"Gary Chambers" <gwchamb@gmail.com> wrote:
>> Has anyone got a proper case function that they are willing to share.
 We're
>> moving from SQL Anywhere to PostgreSQL and decided that much of our data
is
>> upper case when it really should be proper cased.  The columns that we
will
>> be putting proper case data in are all defined using the contrib module
>> citext which makes searching very nice.
>
> Why doesn't the initcap function work as you require?
>
> -- Gary Chambers
>
> /* Nothing fancy and nothing Microsoft! */
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

--
Michael Gould, Managing Partner
Intermodal Software Solutions, LLC
904.226.0978
904.592.5250 fax




Re: Proper case function

От
Tim Landscheidt
Дата:
Michael Gould <mgould@intermodalsoftwaresolutions.net> wrote:

> Based on what I read it wouldn't handle cases where the result should be

> MacDonald from macdonald.  There are other cases such as the sentence below

> ('it''s crazy! i couldn''t believe kate mcdonald, leo dicaprio, (terrence)
> trent d''arby (circa the 80''s), and jada pinkett-smith all showed up to
> [cHris o''donnell''s] party...donning l''oreal lIpstick! They''re heading to
> o''neil''s pub later on t''nite. the_underscore_test. the-hyphen-test)

> This wouldn't handle the quotes and proper case all of the words.
> [...]

Based on your requirements, you want to hire some cheap Eng-
lish native speaker with lots of cultural knowledge.

Tim



Re: Proper case function

От
Seth Gordon
Дата:
Michael Gould wrote:
> Gary,
> 
> Based on what I read it wouldn't handle cases where the result should be
> 
> MacDonald from macdonald.

A function that translates “macdonald” to “MacDonald” would also 
translate “mackintosh” (the raincoat) to “MacKintosh”, unless you write 
it *really really* cleverly.



Re: Proper case function

От
Jasen Betts
Дата:
On 2009-12-31, Michael Gould <mgould@intermodalsoftwaresolutions.net> wrote:
> Gary,
>
> Based on what I read it wouldn't handle cases where the result should be
>
> MacDonald from macdonald.  There are other cases such as the sentence below
>
> ('it''s crazy! i couldn''t believe kate mcdonald, leo dicaprio, (terrence)
> trent d''arby (circa the 80''s), and jada pinkett-smith all showed up to
> [cHris o''donnell''s] party...donning l''oreal lIpstick! They''re heading to
> o''neil''s pub later on t''nite. the_underscore_test. the-hyphen-test)
>
> This wouldn't handle the quotes and proper case all of the words.

There is no case-restoring algorithm that works in all cases.

Some people case their name differently just as some spell their name
differently. Possibly for the same reasons.  

Contact the owners of the names and offer them the opportunity to have 
their name represented in the correct case - send them a link to an online
form.



Re: Proper case function

От
John Summerfield
Дата:
Michael Gould wrote:
> Gary,
> 
> Based on what I read it wouldn't handle cases where the result should be
> 
> MacDonald from macdonald.  There are other cases such as the sentence below

I've looked at rationalising names in this manner before, and found 
that, depending on the individual, both Macdonald and Macdonald are correct.

So I waved my hands around, harrumphed  and went for Macdonald in all cases.

I'm sure that should the MacDonalds have not become accustomed to being 
recorded as Macdonalds, surely they will soon, or at least not complain 
about it.

--