sql - SSIS, Importing multiple datasets from one CSV file -
i have been given set of csv files 2 datasets, neither of fixed length. can suggest how extract datasets file import them seperate tables in sql.
file format
- 17 lines of header information
- word "summary"
- col headers section one
- section 1 * many rows
- blank line
- word "detail"
- col headers section two
- section 2 * many rows
edited
if wants experiment, assuming file this:
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah summary headers1 s1l1 s1l2 s1l3 detail headers2 s2l1 s2l2 s2l3
this script if can use awk
:
awk 'begin{out=""}/summary/{out="1.csv";next}/detail/{out="2.csv";next}/^$/{out="";next} length(out){print > out}' file
at start sets output filename nothing. then, if sees word "summary" sets output filename "1.csv". if sees word "detail" sets output filename "2.csv". on other lines, checks see if output file specified, , writes if is.
your 2 sections end in "1.csv" , "2.csv". script not rely on numbers of lines @ all, words "summary" , "detail".
Comments
Post a Comment