473,473 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Copy and xml files

C G
Dear All,

I'm trying to insert an xml file into my database. I have a table with a
single text column. My intention is just to have the xml file take up one
row in the table.

I've tried the command

COPY t1 FROM '/tmp/file.xml';

but keep getting the error message

ERROR: extra data after last expected column
CONTEXT: COPY t1, line 32: " <cn type="integer"> 1 </cn>"

Thanks for any help

Colin

__________________________________________________ _______________
Sign-up for a FREE BT Broadband connection today!
http://www.msn.co.uk/specials/btbroadband
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 22 '05 #1
2 7027
COPY works for whole tables, and can't append rows. You're going to have to
escape your linebreaks and tabs to use COPY ... As I recall, you can specify
your own custom column and row delimiters... You might consider creating some
type of primary key for the table. A "serial" column would work fine.

If you want to insert a single row into a table, you'll need to do it with an
insert statement. something like :

# psql your_database -c "insert into t1 (xml_column) values ('`cat
/tmp/file.xml | sed -e \"s/'/''/g\"`');"
HTH,

CG

--- C G <cs******@hotmail.com> wrote:
Dear All,

I'm trying to insert an xml file into my database. I have a table with a
single text column. My intention is just to have the xml file take up one
row in the table.

I've tried the command

COPY t1 FROM '/tmp/file.xml';

but keep getting the error message

ERROR: extra data after last expected column
CONTEXT: COPY t1, line 32: " <cn type="integer"> 1 </cn>"

Thanks for any help

Colin

__________________________________________________ _______________
Sign-up for a FREE BT Broadband connection today!
http://www.msn.co.uk/specials/btbroadband
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 22 '05 #2
Chris Gamache wrote:
COPY works for whole tables, and can't append rows. ...

Wrong!

I use copy regularly to add data to a table.
....snip...
--- C G <cs******@hotmail.com> wrote:

Dear All,

I'm trying to insert an xml file into my database. I have a table with a
single text column. My intention is just to have the xml file take up one
row in the table.

I've tried the command

COPY t1 FROM '/tmp/file.xml';

but keep getting the error message

ERROR: extra data after last expected column
CONTEXT: COPY t1, line 32: " <cn type="integer"> 1 </cn>"

Thanks for any help

Colin

If you are trying to import the whole file into one 'column' of a table, you will need to escape the "end of line" [carriage return/line feed] characters.

I believe this question has been asked many times, and the method of importing this type of data is in the archives.

Please check the archives.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Mike | last post by:
I want to be able to copy a directory of files (all .HTM files) from a network drive to a local drive on the machine c:\HTMFiles , How can i do that? I tried File.Copy(source, dest) but i need...
6
by: Wayne Wengert | last post by:
I am using VSNET 2003 to build an ASP.NET/VB set of pages. There are currently about a dozen aspx pages. When I make even a minor change to one page I currently rebuild the solution, copy the...
3
by: Johnny | last post by:
Hi, I have created an ASP.NET application (let's call it FooBar) with VS.NET on my local machine, residing in http://localhost/FooBar. Deploying it to another folder on my machine works well...
2
by: Steve Franks | last post by:
The Copy Web tool provided with VS.NET 2005 is very convenient. However every once in a while it seems to think the files on the remote server have changed, which they have not. Then when I use...
5
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in...
8
by: luis molina Micasoft | last post by:
it seems that when i do file.copy the svchost.exe is hanged, i mean if i make 40 threads of file.copy , 40 copys of files at same time the system is going down and stop responding, this is when i'm...
1
by: dkmarni | last post by:
Hi, I am trying to do this perl script, but not able to complete it successfully. Here is the description what the script has to do.. Accept two and only two command line arguments. Again,...
13
by: jim | last post by:
Is there a way (using VB.Net or C#) to copy open or locked files? Thanks! jim
1
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to...
1
by: =?Utf-8?B?UmFkZW5rb19aZWM=?= | last post by:
I am using standard File.Copy(source,dest,true) method in C# and I have problem with copying large number of files. Here is my code: foreach (FileInfo file in files) {...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.