home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,410 of 19,505   
   Kurt Dicus to All   
   Embedded in text file   
   21 Jul 11 00:17:00   
   
   From: kdicus@dicus.com   
      
   It's been years and years since I used a newsgroup.  Wow.  This brings back   
   some memories!   
      
   Okay, my issue.   
      
   I have an output from a system that generates the following (snipped of   
   relevant info).  The file is ANSI encoded.   
      
    = tab   
    = CRLF   
      
   This would be a perfect file!   
      
   IDSTATUSDESCRIPTIONACTIVE   
   1activeTest description shorttrue   
   2under constructionTest description 2false   
      
   What the file actually looks like.   
   IDSTATUSDESCRIPTIONACTIVE   
   1activeTest   -- it is only the DESCRIPTION field that has the   
   premature break   
   description   
   long stringtrue   
   2under constructionTest description 2false   
      
   There are a limited set of values for the STATUS.  Let's just assume that   
   active and under construction are the only two possible values.   
      
   Before you ask, no, I don't have any way to change the output from the   
   source system -- unfortunately.   
      
   What do you think?  Should I just write a parsing script outside of SQL   
   before the import that builds a correctly formatted file?   
      
   The logic might be something like...   
      
   There are four (and only four) different kinds of lines (excluding the field   
   names)   
   (1) numberstringstringstring   
   (2) numberstringstring   
   (3) string   
   (4) stringstring   
      
   The logic could be something like:   
   If (1), write line to output file.   
   If (2), write line to output file.  Look at next line.  If it is like (3)   
   append to previous line and look at next line assuming previous line isn't   
   complete yet.  If it is like (4), append to previous line and assume a   
   completed line.   
   If (3), make sure previous line looks like (2) or (3).  If so, append to   
   previous line.  If previous line is not like (2) or (3), flag an error.   
   If (4), make sure previous line is like (2) or (3).  If so, append to   
   previous line.  If previous line is not like (2) or (3), flag an error.   
      
   Or, I could do the same basic thing within SQL.  What else?  I need the best   
   idea.   
      
   Thank you to anyone (and everyone) who tries to help.   
      
   Kurt   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca