www.webdeveloper.com
Results 1 to 4 of 4

Thread: Replacing space-delimitor to a tab-delimitor in CSV files?

  1. #1
    Join Date
    Feb 2006
    Location
    Singapore
    Posts
    24

    Replacing space-delimitor to a tab-delimitor in CSV files?


    Holaaaa...
    I have a question about CSV files. I have CSV files that are separated by spacing. Not tab, not comma but spacing.

    I've only come across importing tab-delimited or comma-delimited CSV files to Access but I never heard of importing space-delimited CSV files to Access.

    My CSV files are separated by spaces. I have already done the codes for importing of CSV file to Access but I don't know how to replace the space-delimitor to tab-delimitor.

    Can anyone of you show me where to place the codes & how to do it? Graciass..
    Code:
    <%@ Language="VBScript" %>
    
    <%
      set objconn = Server.CreateObject("ADODB.Connection")
      objconn.Provider="Microsoft.Jet.OLEDB.4.0"
      objconn.Open Server.MapPath("csv.mdb")
    
    
      csv_to_read="test_csv.csv"
      set fso = createobject("scripting.filesystemobject")
      set act = fso.opentextfile(server.mappath(csv_to_read),1,False)
    
      dim sline
      dim sSeg
      
      Do Until act.AtEndOfStream
      
      sline=act.readline
      sSeg=split(sline,",")
    
      dim strsql
      strsql="INSERT INTO CSV (ID, MyName, MyAddress)"
      strsql=strsql & "VALUES('"&sSeg(0)&"', '"&sSeg(1)&"','"&sSeg(2)"')"
    
      objconn.execute strsql
         
      loop
      act.close
      set act=nothing
       
      objconn.close
      set objconn=nothing
    %>
    Hope you people could help me out here. I am really confused now. I had initially thought & assumed that the spaces are the same like tab spacing. But now, I am wrong. I don't know where to continue after this.

  2. #2
    Join Date
    Feb 2006
    Location
    Continental USA
    Posts
    68
    theDIABLA,

    I have a question about CSV files. I have CSV files that are separated by spacing. Not tab, not comma but spacing
    .

    My CSV files are separated by spaces. I have already done the codes for importing of CSV file to Access but I don't know how to replace the space-delimitor to tab-delimitor.

    You are showing code for separating a comma delimited file. So are you asking how to change this to make it separate a space delimited file? I am am confused by the statements.

    Master Shake

  3. #3
    Join Date
    Feb 2006
    Location
    Singapore
    Posts
    24
    Really???? Oohh dear...I guess I did it wrongly then. *grins* Is there different codes to import space-delimited files to Access?? If so, can you help me by posting the sample here so that maybe I can understand??

  4. #4
    Join Date
    Feb 2006
    Location
    Continental USA
    Posts
    68
    Space delimited files are a little more involved since you cannot simply split them. I am assuming your fields are enclosed in quotation marks as well. Are the columns lined up or are they ragged.

    Code:
    Do they look like this:
    "   1" "George Bernard Shaw" "1 Whiskey River, Blah NM 99999"
    " 111" "Millicent Harper"    "2 Holloway Lane, Blaine MO 77777"
    
    or do they look like this:
    "1" "George Bernard Shaw" "1 Whiskey River, Blah NM 99999"
    "111" "Millicent Harper" "2 Holloway Lane, Blaine MO 77777"
    The top one is easier than the bottom one. Let know exactly what I will have to deal with and I can help you. Just out of curiosity where are you getting these from and can you have them changed to normal CSV's (comma delimited)

    Master Shake

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles