Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Import from comma delimeted text file

Posted on 2000-03-01
3
240 Views
Last Modified: 2013-12-18
Hi,

How can I easily import to a view a text file (MS Proxy Server Log File) that is comma delimeted?  It will be one document per line. And it must able to interpret Date/Time Field.


Reden
0
Comment
Question by:reden
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Arunkumar
ID: 2572172
Hi reden,

You got to have a form for this imported documents to be viewed.

Did you try importing txt files using the notes import feature File-Import

You can specify the form and also calculate the ields on document import.

You can improve your import by writing a format file with .col extn.

Also you can import using LotusScript
one line after another and creating a document for each read.

With which one you have a problem ?

-Arun
0
 
LVL 1

Author Comment

by:reden
ID: 2575939
I already have a form, I tried File-Import Feature but it only have Tabular, Structured and Lotus 123 formats supported, If I try Tabular it goes in to a single field "Body"

How will I create a .col file?
0
 
LVL 9

Accepted Solution

by:
Arunkumar earned 50 total points
ID: 2579675
Hi reden,

This is an example i have with me....

The text File has something like this...

======================================
aruna,27,09-15-72,3000
arunb,27,09-15-72,3022
arunc,27,09-15-72,3033
arund,27,09-15-72,3044
arune,27,09-15-72,3055
arunf,27,09-15-72,3066
arunh,27,09-15-72,30546
arunf,27,09-15-72,30345
arung,27,09-15-72,30432
aruns,27,09-15-72,30445
======================================

Write a view action that will contain the following code

====================================
Dim ss As New notessession
Dim ws as new notesuiworkspace
     Dim db As notesdatabase
     Set db = ss.CurrentDatabase    
     Dim doc As notesdocument
     Dim wholetxt As String
     Dim fileNum As Integer
     Dim counter As Integer
     Dim countRec As Integer
     
     fileNum% = Freefile()
     counter% = 0
'Specify the file    
     Open "c:\windows\desktop\import.txt" For Input As fileNum%
     Do While Not Eof(fileNum%)
   ' Read each line of the file.
          Line Input #fileNum%, wholetxt$
         
          pos = Instr(1,wholetxt,",")
          firsttxt = Left(wholetxt, pos -1)
          remtxt = Right(wholetxt , Len(wholetxt) - (Len(firsttxt) + 1))
         
          pos = Instr(1,remtxt,",")
          secondtxt = Left(remtxt , pos-1)
          remtxt = Right(remtxt , Len(remtxt) - (Len(secondtxt) + 1))
         
          pos = Instr(1,remtxt,",")
          thirdtxt = Left(remtxt , pos-1)          
          remtxt = Right(remtxt , Len(remtxt) - (Len(thirdtxt) + 1))
         
'          pos = pos = Instr(1,remtxt,",")
          fourthtxt = remtxt
'          remtxt = Right(remtxt , Len(remtxt) - (Len(fourthtxt) + 1))
         
         
          Set doc = db.CreateDocument
          doc.form = "import"
          doc.NameField = firsttxt
          doc.AgeField = secondtxt
          doc.dobField = Cdat(Format(thirdtxt,"MM/DD/YYYY"))
          doc.salField = fourthtxt
          Call doc.Save(True,False)          
          Delete doc
         
   ' Increment the line count.
          counter% = counter% + 1
     Loop

call ws.viewrefresh

====================================

Some tips:
1. Make sure you give the exact filepath for the location of the file
2. Make sure that you change the datatype of the fields that you want to create on the document (This decides the datatype of the fields)
3. The code works for only 4 fields and you may extend this to "n" just by cut and pasting the logic inside

Good Luck !

-Arun

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question