473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Inputting columns of data

C G
Dear All,

I have a text file with data like:
1 2 3
4 5 6
7 8 9
i.e. so I have three columns of numbers.

I wish to put this data into a table. However, I do not want it to take up
three rows, rather only a single row and a single column. I was think
something like this

CREATE TABLE t1(data numeric[]);
INSERT INTO TABLE t1 VALUES ('{1 4 7, 2 5 8, 3 6 9}')

but this does not work.

What's the best way of approaching this problem? All the files I'll put into
the table will not have the same number of columns, or be the same length. I
would only like to access a single column of data, but never a single
number.

Many thanks

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
1 1252
On Monday 16 February 2004 15:46, C G wrote:
Dear All,

I have a text file with data like:
1 2 3
4 5 6
7 8 9
i.e. so I have three columns of numbers.

I wish to put this data into a table. However, I do not want it to take up
three rows, rather only a single row and a single column. I was think
something like this

CREATE TABLE t1(data numeric[]);
INSERT INTO TABLE t1 VALUES ('{1 4 7, 2 5 8, 3 6 9}')

but this does not work.
I'm not sure what you thought it would do - this is supposed to be a three
element array of what type?
Oh - you don't need the "TABLE" on the insert either.
What's the best way of approaching this problem? All the files I'll put
into the table will not have the same number of columns, or be the same
length. I would only like to access a single column of data, but never a
single number.


Define your table:
CREATE TABLE t1 (data text);
INSERT INTO t1 VALUES ('1 2 3 4 5 6 7 8 9');

That'll store pretty much anything you like. If you need null values you might
want to investigate bytea type.

On the other hand, that's a poor way of using a relational database - can you
explain what you are trying to achieve? Someone might have a better way to do
it.
--
Richard Huxton
Archonet Ltd

---------------------------(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

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

Similar topics

8
by: pmud | last post by:
Hi, I have 2 questions: 1. I have an editable data grid with 21 columns. I need to edit only 2 cloumns in this data grid. But when the grid is displayed in Edit mode, all the columns show long...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
5
by: Gary Blakely | last post by:
I'm giving this post another try - it can't be too difficult for everyone.... In the program below, the web page has dataGrid1. the only thing that has been done to it at design time is to...
4
by: Mortar | last post by:
i need a datagrid with 2 header columns. The top one might have 1 column spanning 5 columns of the header row below it. what is the best way to do this? Could i have 2 datatables...1 filling the...
0
by: jasonwong | last post by:
Hi, I was wondering if anyone knows of a way to utilize the Runtime Parser to parse a text box filled with user input code. The user will be inputting HTML and data markup into a textbox that...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
1
by: Ramper | last post by:
Have a .txt document as: String int int int int int int int
5
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can...
5
by: tim123 | last post by:
Hey. I'm having some issues reading in data from a tab delimited text file. I only want to input numbers, and ideally I'd like it to be able to cope with a line or 2 of text at the top in case...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.