From csv to db with dbimport: Howto?
Posted in 1999
Topics: Migration, Import/Export & Data Conversion
The subject line says it all. I have pored over a myriad of on-line
docs, and yet have no idea what is the proper ascii format my old
data file needs to have. Also, the attendant schema file is alleged
to require a format so that dbimport will actually create a database.
My basic plan is to take the data out of a spreadsheet in csv
format, read it into Informix SE, and enjoy life to the fullest. :^)
Please point me to a good reference, or if it is short and sweet,
RSVP.
Chris
Hi Chris
In general the format that most informix people are familiar with is pipe
delimited data. Hence a normal data file will look like : -
field 1|field 2| etc | etc |
As your data is in csv format you have a couple of choices ignored to load
it into the database.
There is an informix env variable called $DBDELIMITER which you could set or
you could use the following bit of shell to swap the commas to pipes.
#!/bin/ksh
for file in $(ls *csv)
do
echo "Transforming ${file} from csv to unl"
cat ${file} | sed -e 's/,/|/g > $(echo ${file} | awk -F'.'
'{printf("%s.unl\\n", $1);}')
done
exit 0
Either if the above will get your data into the correct format.
You also mentioned about using dbimport to get both the database and data
into Informix SE. This is going to be a little more fun for you.
dbimport have very specific rules about directory naming and the command
lines contained within the .SQL file. If you really want to do this create
an informix demo database and perform a dbexport. From this you will get
the format of the file and hence be able to change it.
However, if I was you I would not bother. I would be more tempted to just
create my database and them use SQL to load my datafiles. Again, this is
something that could be done from shell script.
Regards
Sean
bobnospam@khusro.math.umn.edu wrote in message
<1999Feb12.152326@khusro.math.umn.edu>...
>The subject line says it all. I have pored over a myriad of on-line
>docs, and yet have no idea what is the proper ascii format my old
>data file needs to have. Also, the attendant schema file is alleged
>to require a format so that dbimport will actually create a database.
>
>My basic plan is to take the data out of a spreadsheet in csv
>format, read it into Informix SE, and enjoy life to the fullest. :^)
>
>Please point me to a good reference, or if it is short and sweet,
>RSVP.
>
>Chris
Hi Chris,
I have written a program that you can use to port the data. It is called
WinSQL and allows you to port data from one database to other. You will
need an ODBC driver for informix and text files. Go to
http://www.imranweb.com/freesoft and get WinSQL Professional.
Thanks,
Imran.
bobnospam@khusro.math.umn.edu wrote:
>
> The subject line says it all. I have pored over a myriad of on-line
> docs, and yet have no idea what is the proper ascii format my old
> data file needs to have. Also, the attendant schema file is alleged
> to require a format so that dbimport will actually create a database.
>
> My basic plan is to take the data out of a spreadsheet in csv
> format, read it into Informix SE, and enjoy life to the fullest. :^)
>
> Please point me to a good reference, or if it is short and sweet,
> RSVP.
>
> Chris
--
===========================================
Imran Hussain
MCP, MCSD
imranh@imranweb.com
For FREE Software http://www.imranweb.com/freesoft
===========================================
You should use dbload instead of dbimport. dbimport will create and load
complete database.
dbload can load specific tables, and you can specify format (fixed or csv),
together with
number of lines to be loaded between comits, error handling etc. Details and
formats can be found in
IDS Administrator's guide.
Regards
==============================
Slobodan Zorko
Alfatec Group
10000 Zagreb, Kranjceviceva 36, CROATIA
email: slobodan.zorko@zg.tel.hr
begin 666 Sobodan Zorko.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..EIO<FMO.U-O8F]D86X-"D9.
M.E-O8F]D86X@6F]R:V\\-"D]21SI!;&9A=&5C($=R;W5P#0I4251,13I496-H
M(%-U<'!O;W)T#0I414P[5T]22SM63TE#13HK,S@U("@Q*2 S-C0W(# W-PT*
M5$5,.U=/4DL[1D%8.BLS.#4@*#$I(#,V-#8@-S<U#0I!1%([5T]22SH[.TMR
M86YJ8V5V:6-E=F$@,S8[6D%'4D5".TA2.S$P,# P.T-23T%424$-"DQ!0D5,
M.U=/4DL[14Y#3T1)3D<]455/5$5$+5!224Y404),13I+<F%N:F-E=FEC979A
M(#,V/3!$/3!!6D%'4D5"+"!(4B Q,# P,#TP1#TP04-23T%424$-"E523#H-
M"E523#IH='1P.B\\O=W=W+F%L9F%T96,N:'(-"D5-04E,.U!2148[24Y415).
M150Z<V]B;V1A;BYZ;W)K;T!Z9RYT92YH<@T*4D56.C$Y.3DP,C$U5#$P-3@P
/-%H-"D5.1#I60T%21 T*
`
end
In article <1999Feb12.152326@khusro.math.umn.edu>, bobnospam@khusro.math.umn.edu writes:
|> The subject line says it all. I have pored over a myriad of on-line
|> docs, and yet have no idea what is the proper ascii format my old
|> data file needs to have. Also, the attendant schema file is alleged
|> to require a format so that dbimport will actually create a database.
|>
|> My basic plan is to take the data out of a spreadsheet in csv
|> format, read it into Informix SE, and enjoy life to the fullest. :^)
|>
|> Please point me to a good reference, or if it is short and sweet,
|> RSVP.
|>
|> Chris
Many thanks for all the help.
Chris