473,408 Members | 1,759 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,408 software developers and data experts.

Importing headers

I have a text file with 180 headers.
Is it possible to import this file into mysql where mysql will
automatically create the table with column headings from the headers
(as sql server and access do?)

In case that doesn;t work, how can I create the table and past the
header names into th command line, or use a text file to impoprt the
headers in somehow?

Last question, am I gonna be sitting there doing a 160+ field create
table statement? Please say no.
Jul 20 '05 #1
1 2464
to****@NOSPAMnterport.net wrote:
I have a text file with 180 headers.
Is it possible to import this file into mysql where mysql will
automatically create the table with column headings from the headers
(as sql server and access do?)
I can't find an option like this in the docs for the mysqlimport tool or
its statement equivalent, LOAD DATA INFILE. It seems from the docs that
you must have a table created before you can import into it from a text
file. I don't know if another tool exists to do what you want.
In case that doesn;t work, how can I create the table and past the
header names into th command line, or use a text file to impoprt the
headers in somehow?


If it were me, I'd write a Perl script to parse the headers in the text
file, and generate an appropriate CREATE TABLE statement from them.
For instance:

head -1 textfile | perl -ane 'print "CREATE TABLE myTable (\n\t",
join(",\n\t", map("$_ VARCHAR(100)", @F)), "\n);\n";'

Edit the resulting CREATE TABLE statement if you want to change some of
the column defs, and then run the statement using the mysql tool.

Then use mysqlimport to load the rest of the data from the file into the
table.

Regards,
Bill K.
Jul 20 '05 #2

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

Similar topics

2
by: Alexis Francart | last post by:
Hello, I want to use a program called maxq. This program is used for functionnal and regression test of web application. The language it uses is Jython. I need to get a part of a web page using...
1
by: torjon | last post by:
I have a text file with 180 headers. Is it possible to import this file into mysql where mysql will automatically create the table with column headings from the headers (as sql server and access...
4
by: tgru | last post by:
Hello, I need to import a bunch of .csv files. The problem I am having is the "non data" information in the files creating bogus rows and column definitions. Here is an example of the csv file....
1
by: alex dai | last post by:
Hello, I have an old project which used statement like this: #include <iomanip.h> I searched my whole VS.net installation directory, but no file named iomanip.h found. There is do a iomanip.h...
12
by: Jonathan | last post by:
How do you tell the .csv file that you are to import that it has no row headers as I went to the web site http://www.connectionstrings.com/ and under text file it says: "HDR=Yes;" indicates that...
0
by: wgcrouch | last post by:
I am trying to write a procedure to import some tab separated files that are generated by another program. The problem I am having is they have a line of text before the field headers and therefore...
12
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the...
4
by: Duncan Smith | last post by:
I have a VS2005 C++ MFC project which #imports a type library. The goal is to introduce some managed code eventually, but for starters I just need to set the /clr compiler option and build the...
4
by: johnporter123 | last post by:
Does anyone have a method of importing a large "FLAT" CSV file into access. The file has well over 255 columns (Fields). Before anyone flames me over normalization, I do not have access to the...
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
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
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...
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,...
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...

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.