![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an output file from another product which has a variable number of columns, followed by the row-terminator. The first four columns are always present, the remaining 6 may or may not be present in some number. I would like to load that data into a Sybase ASE 11.5.1 table which has 10 columns, where the first four columns are the only NOT NULL columns in the table. I have tried using bcp -- both with tab-delimited input and with fixed-length input -- but the load is garbage, since bcp seems to wrap to the next row to get all 10 columns. Is there any option I can use to achieve my end, or does anyone have an alternative suggestion? Thank you. |
#3
| |||
| |||
|
|
You could massage your data to produce 10, tab-delimited fields for each line of input. If you have Perl, try the following stdin/stdout filter for each input file: #!/usr/bin/perl while(<>) { chomp; print join("\t",(@x = split /\t/)), "\t" x (9 - $#x), "\n"; } |
#4
| |||
| |||
|
|
pjhoust (AT) canada (DOT) com wrote: You could massage your data to produce 10, tab-delimited fields for each line of input. If you have Perl, try the following stdin/stdout filter for each input file: #!/usr/bin/perl while(<>) { chomp; print join("\t",(@x = split /\t/)), "\t" x (9 - $#x), "\n"; } } Well, unfortunately that didn't quite work. I substituted the pipe character "|" and used input and output files, and I really had 13 (rather than 10) columns so I ran: open (INFILE, "<Myinput.txt"); # open input file open (OUTFILE, ">Myoutput.txt"); # open output file while(<INFILE>){ chomp; print OUTFILE join ("|", (@x = split /|/)), "|" x (12 - $#x), "\n"; } } Instead of 13 columns delimited by the pipe character, with trailing ones empty, I ended up with every character of the input line delimited by the pipe character, including the pipe character delimited by the pipe character, with no "extra" pipes at the end. |
![]() |
| Thread Tools | |
| Display Modes | |
| |