![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
This is a really strange problem. I'm forced to read in CSV data as fixed-length because the amount of data per row varies and they can't provide additional commas to make a set number of columns. This works fine as I'm just converting most of each row into a varchar column by replace commas with CHAR(1)'s. However, I've noticed that I'm either not reading in the entire row to insert into the database or otherwise losing data from this import. Import goes into a work table first, then to the actual DB table. Work table has a varchar(2000) column to hold the data. Example - I'll read in a CSV row with 21 entries. 1 gets stripped off for another column - the others go into my varchar column with the replace as above. That same CSV file has another row with 17 columns. 1 stripped off, the others to be inserted. However, in this case when I look at the database, only 13 of those columns were inserted. I'm stuck here. I'm not truncating data consistently at some actual column in the text file. It works most of the time and will even fail on shorter columns which leads me to believe there's something that's either not reading the data correctly from the file or is truncating that row's data randomly during the INSERT/SELECT SQL Command I'm running. When I re-import the same file, I don't see any issues at all - can issue an update to the desired column to fix the data, however this doesn't help me overall because the data is operated on shortly after it's been inserted. Am I missing something here? Has anyone experienced something similar? Thanks in advance, -Peter Schott |
#3
| |||
| |||
|
|
OK let me recap your scenario You import a CSV into a table as fixed length. That length is never > 2000 chars You import to a work table. Values in the worktable correct? what does 1 column get stripped off for? The data is either going missing here or in your move to the proper table which? Variable length rows is really ugly which is why this was written http://www.databasejournal.com/featu...le.php/1462341 |
![]() |
| Thread Tools | |
| Display Modes | |
| |