Import in the DB Access CSV files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mike1961
    New Member
    • Apr 2008
    • 66

    Import in the DB Access CSV files

    Hi all.

    With ASP I read and register in the DB ACCESS, this lines a CSV file:

    Code:
    29/06/2008 00:15:48
    29/06/2008 00:34:54
    29/06/2008 07:28:03
    29/06/2008 07:38:03
    29/06/2008 08:52:33
    29/06/2008 12:43:14
    29/06/2008 13:18:58
    29/06/2008 14:26:04
    29/06/2008 15:28:05
    29/06/2008 15:39:13
    29/06/2008 15:42:54
    29/06/2008 16:09:16
    29/06/2008 17:18:46
    29/06/2008 19:27:23
    29/06/2008 21:27:23
    You can exclude the lines when difference between the first row and the second row less than 30 minutes?

    For example:

    Code:
    29/06/2008 00:15:48	Yes
    29/06/2008 00:34:54	Not
    29/06/2008 07:28:03	Yes
    29/06/2008 07:38:03	Not
    29/06/2008 08:52:33	Yes
    29/06/2008 12:45:14	Yes
    29/06/2008 13:10:58	Not
    29/06/2008 14:26:04	Yes
    29/06/2008 15:28:05	Yes
    29/06/2008 15:39:13	Not
    29/06/2008 15:42:54	Not
    29/06/2008 16:09:16	Yes
    29/06/2008 17:18:46	Yes
    29/06/2008 19:27:23	Yes
    29/06/2008 21:27:23	Yes
    It' possible?
    Any suggestions ?

    Thanks, regards
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Mike,

    Rather than trying to explain this one I've written a bit of pseudo-code to help you:

    Code:
     Dim Row1_Time, Row2_Time 
    Dim flagDiff
    Do Until oRS.EOF
     
    	 'Get the values from the first row
    	 Row1_Time = oRS("Time")
     
    	 'Move the recordset on to the next record
    	 oRS.MoveNext
     
    	 'Get the values from the second row
    	 Row2_Time = oRS("Time")
     
    	 'Check the difference between them and set the flag
    	 If difference between Row1_Time and Row2_Time < 30 minutes Then
    		 flagDiff = "Yes"
    	 Else
    		 flagDiff = "Not"
    	 End If
     
    	 'Now write the FIRST line to the CSV file
    	 Response.Write Row1_Time & flagDiff 
     
    'Now loop back to the start. You DON'T move on to the next record at this point because you want the record which is currently stored as Row2 to be set as Row1 on the next loop
    Loop
    Hopefully you can use this example to build a working script. Let me know how you get on.

    Dr B

    EDIT: Just thought about it and you'll need to do a check that the recordset is not EOF before you try to move to the next record or it will error when it reaches the last one.

    Comment

    • Mike1961
      New Member
      • Apr 2008
      • 66

      #3
      thank's ! it's right !

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        No problem, glad I could help.

        Dr B

        Comment

        Working...