dbTalk Databases Forums  

importing csv files with different number of columns.

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss importing csv files with different number of columns. in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
CravenStu
 
Posts: n/a

Default importing csv files with different number of columns. - 11-22-2005 , 10:48 AM






Hi

I have created a DTS as part of my month end process to import 40 different
csv files from our various sales offices.

Each file contains the account no and purchase information for the entire
month. eg

13245, box1, box5, box4
45897, box9, box3, box5, box2
98765, box1

The maximum number of boxes is 9, so any row in the csv file could have up to
10 columns (including account number), but if a customer only purchases 1 box
there will only be 2 coluns.

The problem I have is that when I execute the DTS it will only bring through
the 1st 3 boxes and put nulls in all the other columns.

Is there a way to change the Transform Data Task Properties for each files
using VB depending on the maximum number of columns in each files.

This has really stumped me so any help or alternative ways of doing this
would greatfully recieved.

Thanks

Reply With Quote
  #2  
Old   
mattb
 
Posts: n/a

Default RE: importing csv files with different number of columns. - 11-22-2005 , 02:19 PM








"CravenStu" wrote:

Quote:
Hi

I have created a DTS as part of my month end process to import 40 different
csv files from our various sales offices.

Each file contains the account no and purchase information for the entire
month. eg

13245, box1, box5, box4
45897, box9, box3, box5, box2
98765, box1

The maximum number of boxes is 9, so any row in the csv file could have up to
10 columns (including account number), but if a customer only purchases 1 box
there will only be 2 coluns.

The problem I have is that when I execute the DTS it will only bring through
the 1st 3 boxes and put nulls in all the other columns.

Is there a way to change the Transform Data Task Properties for each files
using VB depending on the maximum number of columns in each files.

This has really stumped me so any help or alternative ways of doing this
would greatfully recieved.

Thanks

import data into excel, text to columns, line-up data, add zeros, then save
file and dts into sql.
although other than for speed of insertions, you really DO want the null
values in the tables.


Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: importing csv files with different number of columns. - 11-22-2005 , 03:32 PM



So what do you want to do?

Read the line as a single string and then SPLIT() the row on commas.
You now know how many elements are in thaat row. You can do with it
then as you please


Like this

Processing The Same Row More Than Once
(http://www.sqldts.com/default.aspx?266)


What does you destination look like?

It sounds as though it looks like this

Account#,
Purchase#1
Purchase#2,
Purchase#3,
Purchase#4,
Purchase#5,
Purchase#6,
Purchase#7,
Purchase#8

Is tht correct?

Allan


"CravenStu" <u16001@uwe> wrote


Quote:
Hi

I have created a DTS as part of my month end process to import 40
different
csv files from our various sales offices.

Each file contains the account no and purchase information for the
entire
month. eg

13245, box1, box5, box4
45897, box9, box3, box5, box2
98765, box1

The maximum number of boxes is 9, so any row in the csv file could have
up to
10 columns (including account number), but if a customer only purchases
1 box
there will only be 2 coluns.

The problem I have is that when I execute the DTS it will only bring
through
the 1st 3 boxes and put nulls in all the other columns.

Is there a way to change the Transform Data Task Properties for each
files
using VB depending on the maximum number of columns in each files.

This has really stumped me so any help or alternative ways of doing this
would greatfully recieved.

Thanks


Reply With Quote
  #4  
Old   
CravenStu via SQLMonster.com
 
Posts: n/a

Default Re: importing csv files with different number of columns. - 11-23-2005 , 02:56 AM



Thanks Allen,

you are correct about the destination table layout. I will try your idea
today.

Cheers

Stu

Allan Mitchell wrote:
Quote:
So what do you want to do?

Read the line as a single string and then SPLIT() the row on commas.
You now know how many elements are in thaat row. You can do with it
then as you please

Like this

Processing The Same Row More Than Once
(http://www.sqldts.com/default.aspx?266)

What does you destination look like?

It sounds as though it looks like this

Account#,
Purchase#1
Purchase#2,
Purchase#3,
Purchase#4,
Purchase#5,
Purchase#6,
Purchase#7,
Purchase#8

Is tht correct?

Allan

Hi

[quoted text clipped - 28 lines]

Thanks
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums...r-dts/200511/1


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.