CSV Field Truncation

Results 1 to 2 of 2

Thread: CSV Field Truncation

  1. #1
    Join Date
    Dec 1969

    Default CSV Field Truncation

    I have managed to write a page that uploads a csv file, connects to it via ADO and then uload the fields into a database. I am having a problem with fields over 255 characters in length, the field gets truncated at this point. Is there any way around this?<BR><BR>I have tried doing it manually (split by comma) but some fields (wrapped with "") have commas in and I cant get my head around how to sort that.<BR><BR>Thanks to anyone that can help.

  2. #2
    Join Date
    Dec 1969

    Default Can't help on the 255 limit...

    ...for CSV. Didn&#039;t know there was one, but give the limits of the JET drivers, it makes sense.<BR><BR>But doing it manually isn&#039;t too bad.<BR><BR>I showed something very similar the other day, in fact. Probably never find it again...let me look...<BR><BR>Nope. Okay let&#039;s hack at it.<BR><BR>&#060;%<BR>line = infile.ReadLine<BR>inItems = Split( line, "," ) &#039; split on commas<BR><BR>Dim out(...) &#039; assumed to have an array of fields, ubound as expected<BR><BR>inNum = 0 <BR><BR>For outNum = 0 To UBound(out)<BR> item = inItems(inNum)<BR> If Left(item,1) = """" Then &#039; if starts with quote<BR> &#039; if there was a comma in the quoted string,<BR> &#039; the put the quoted string back together again!<BR> Do Until Right(item,1) = """" &#039; find ending quote<BR> inNum = inNum + 1<BR> item = item & "," & inItems(inNum)<BR> Loop<BR> &#039; get rid of quotes on front and back<BR> item = Mid( item, 2, Len(item)-2 )<BR> End If<BR> out(outNum) = item<BR> inNum = inNum + 1<BR>Next<BR><BR>&#039; now the out array is ready to use<BR>%&#062;<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts